Deploying Node backend on Render and getting a Sequelize and Postgres connection error

I connected to my GitHub repo, added env var for access token, refresh token and node version, plus added a secret file with the rest of the contents of the .env file I use in dev mode. The deployment process ran smoothly until the npm start. It started nodemon, started the index.js file, showed “models in db: 2” and then the connection error popped up: Error: SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:5432. Here are the screen shots of what followed:

Any suggestions welcomed. Thanks

This is my db.js where I configure the connection:

Why is your address at 127.0.0.1? Thats a localhost, where are you hosting your database? If youre using your render db this is wrong, you should be using the url provided to you at the database dashboard

1 Like

Yeap, that was it! I did not set my db in the dashboard. Beginners errors, first time deploying on Render. Thanks for the tip!

I had to rearrange the order of the variables in the sequelize instance and in the secret .env file to reflect the order they appear in the db service (it seems to matter). The variables I used: Hostname, Port, Database, Username and Password. This is db.js set up that finally worked:

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