Unable to connect to Postgres DB from Railway Instance

parik36TRIAL

a year ago

I deployed a NodeJS Express backend using Railway, and I also spun up a Postgres instance. I have the connection URL of the database, but I am unable to connect to it via the backend instance.

I can connect to the database using the connection URL from my local machine, localhost, as well as from TablePlus. I just cannot seem to get the two services connected.

I tried using both the Database URL and Private Database URL Shared Variables, but no luck. I still get the same error, any help folks?

P.S. I am using Prisma ORM in my backend, and I get this error:

npm WARN config production Use --omit=dev instead.

@company/product-server@1.0.0 start

node dist/app.js

PrismaClientInitializationError:

Invalid prisma.$queryRaw() invocation:

Can't reach database server at monorail.proxy.rlwy.net:50236

Please make sure your database server is running at monorail.proxy.rlwy.net:50236.

at si.handleRequestError (/app/node_modules/@prisma/client/runtime/library.js:125:7117)

at si.handleAndLogRequestError (/app/node_modules/@prisma/client/runtime/library.js:125:6151)

at si.request (/app/node_modules/@prisma/client/runtime/library.js:125:5859)

at async l (/app/node_modules/@prisma/client/runtime/library.js:130:10025) {

clientVersion: '5.7.1',

errorCode: undefined

}

3 Replies

parik36TRIAL

a year ago

To anybody having this problem, I resolved it by adding a delay during the start using a custom start command: sleep 3 && npm start.


a year ago

interesting…is this still working for you?


ferrefabio1987TRIAL

a year ago

I use yarn before which command?


Unable to connect to Postgres DB from Railway Instance - Railway Help Station