MySQL connection issue

I’m getting a MySQL error when deploying my Node.js application. When developing project, a user can register or login into the system. However, after deployment page keeps refreshing and cannot login into the system. The error is :

Error: connect ECONNREFUSED 127.0.0.1:3306
Feb 7 07:55:42 PM at PromisePool.query (/opt/render/project/src/node_modules/mysql2/promise.js:341:22)
Feb 7 07:55:42 PM at exports.login (/opt/render/project/src/controllers/kullanıcılar.js:25:33)
Feb 7 07:55:42 PM at Layer.handle [as handle_request] (/opt/render/project/src/node_modules/express/lib/router/layer.js:95:5)
Feb 7 07:55:42 PM at next (/opt/render/project/src/node_modules/express/lib/router/route.js:144:13)
Feb 7 07:55:42 PM at Route.dispatch (/opt/render/project/src/node_modules/express/lib/router/route.js:114:3)
Feb 7 07:55:42 PM at Layer.handle [as handle_request] (/opt/render/project/src/node_modules/express/lib/router/layer.js:95:5)
Feb 7 07:55:42 PM at /opt/render/project/src/node_modules/express/lib/router/index.js:284:15
Feb 7 07:55:42 PM at Function.process_params (/opt/render/project/src/node_modules/express/lib/router/index.js:346:12)
Feb 7 07:55:42 PM at next (/opt/render/project/src/node_modules/express/lib/router/index.js:280:10)
Feb 7 07:55:42 PM at Function.handle (/opt/render/project/src/node_modules/express/lib/router/index.js:175:3) {
Feb 7 07:55:42 PM code: ‘ECONNREFUSED’,
Feb 7 07:55:42 PM errno: -111,
Feb 7 07:55:42 PM sql: undefined,
Feb 7 07:55:42 PM sqlState: undefined,
Feb 7 07:55:42 PM sqlMessage: undefined
Feb 7 07:55:42 PM }

MySQL server is working on port 3306, and my node server listening on port process.env.port||3307. Why am I getting this error, can you help please?

The first line of your error is the answer:

 Error: connect ECONNREFUSED 127.0.0.1:3306

That’s trying to connect to mySQL on the same host as the Node application, that’s not likely to be correct,

Regards,

John B

1 Like

Thanks for the quick answer, what should i do to handle this problem, any ideas?

You’ll need to have a mySQL database deployed somewhere. We have an example at https://render.com/docs/deploy-mysql but this will be a paid service.

Regards

John B

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