Cannot connect to mySQL DB from backend service

Hey,
First of all I just wanna say I’ve seen posts about it, but they were automatically closed before an elaborated answer was given.

To my issue:
I have a frontend (Static File with React) and backend (Nodejs Express) deployed on Render.
I’ve had a struggle finding out how to redirect api calls from localhost:4000 to my render’s site backend url.
now the thing is, I see in my backend logs that I cannot connect to the server:
Jun 23 07:37:09 PM Error in dal_mysql.ts: Error: connect ECONNREFUSED 127.0.0.1:3306
Jun 23 07:37:09 PM at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
Jun 23 07:37:09 PM errno: -111,
Jun 23 07:37:09 PM code: ‘ECONNREFUSED’,
Jun 23 07:37:09 PM syscall: ‘connect’,
Jun 23 07:37:09 PM address: ‘127.0.0.1’,
Jun 23 07:37:09 PM port: 3306,
Jun 23 07:37:09 PM fatal: true
Jun 23 07:37:09 PM }

I dont see an option to connect mySQL to Render, so I was wondering, what should I do / check / update so mySQL DB will be accessible by my Render site?

If any extra information is needed please tell me.

Thanks in advance!

Hi there,

Render does not offer MySQL as managed service. You can switch your backend to use Postgres, as this is a service we offer or run your own MySQL. You could also use a 3rd party to run your MySQL service.

I’m not sure if this solves the question of:

I’ve had a struggle finding out how to redirect api calls from localhost:4000 to my render’s site backend url

As they may be a separate issue.

Check your frontend config to make sure you are not hardcoding your call to your API with localhost:4000, You probably want to use an environment variable to set your API endpoint.

Regards,

Keith
Render Support, UTC+10 :australia:

I’ve managed to redirect api calls from localhost:4000 to my example-api.onrender.com.
Its just the issue with mySQL connection.
I’ll seek for 3rd party solutions to run mySQL service and look into Render’s Postgres solution.

Thanks

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.