0

I was trying to deploy my first backend project made with** express, sequelize and postgresql** until I got the above error when Railway (the service I am using for deploying) was running the "npm start command". That doesn't happen locally. I checked all my evironment variables and nothing it's wrong. Any idea of what could it be? I was thinking of my internet connection but it is right too.

I searched tutorials of "How to deploy" and "How to deploy on Railway" and even checked the Railway documentation but it didn't help either. This is a really unexpected error since my project works well locally.

I was expecting something like this:

`npm WARN config production Use `--omit=dev` instead.
> api@1.0.0 start
> node index.js
> Listening on port [2345 for example]`

But I got this instead:

`ConnectionError [SequelizeConnectionError]: connect ETIMEDOUT 
at Client._connectionCallback (/app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:143:24)
at Client._handleErrorWhileConnecting (/app/node_modules/pg/lib/client.js:318:19)
at Client._handleErrorEvent (/app/node_modules/pg/lib/client.js:328:19)
at Connection.emit (node:events:513:28)
at Socket.reportStreamError (/app/node_modules/pg/lib/connection.js:57:12)
at Socket.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
parent: Error: connect ETIMEDOUT 35.230.48.98:5432
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16) {
errno: -110,
code: 'ETIMEDOUT',
syscall: 'connect',
address: 'The address',
port: My Port
},`
gunman
  • 1
  • 1

1 Answers1

0

Railway doesn't have any information regarding their network or IP ranges that I could find. You have to, within the SQL tab of your google cloud console, click the Connections tab and subsequently the Networking tab. Finally, allow connections from IP 0.0.0.0. However, before doing so, make sure you add a User to your cloud instance with a username and password. Provide the values of said username and password as environment variables with your database connection code. Like so,

let sequelize = new Sequelize(process.env.GOOGLE_DB_NAME, process.env.RAILWAY_USERNAME, process.env.RAILWAY_PASSWORD, { host: process.env.GOOGLE_HOST, dialect: 'mysql', port: 3306 })

Include said variables in your railway client Variables tab.

I hope this helps