MySQL Connection Error in Production
jcbeho
HOBBYOP

2 years ago

I am experiencing an issue when trying to connect my application to the MySQL database in production. Despite the backend and frontend environment variables being correctly configured and the request responses being coherent, I keep receiving the following error:

Error: connect ECONNREFUSED ::1:3306

I have verified that the environment variables (MYSQLHOST, MYSQLUSER, MYSQLPASSWORD, MYSQLDATABASE, MYSQLPORT) are correctly defined and confirmed that I can connect to the database from the terminal using these same parameters.

3 Replies

2 years ago

Can you please send a screenshot of your service variables, sans anything sensitive.


jcbeho
HOBBYOP

2 years ago

PORT = 4000

DB_HOST = localhost

DB_PORT = 3306

DB_USER = root

DB_PASSWORD = *****

DB_DATABASE = *****


2 years ago

Those would be the incorrect variables, please use reference variables to reference the variables your mysql database exposes.

https://docs.railway.app/guides/variables#referencing-another-services-variable

Please note your database needs to be in the same project for this to work correctly.


Loading...