3 months ago
I just tried to deploy some code changes for my service and noticed how suddenly my service can't connect to the postgres database using the DATABASE_URL. It has worked wonderfully for the last couple of days.
I've tried and I can connect to the postgres database using the public database url on my local machine, but something makes my app not able to reach it. Are they still on the same network?
I've had this problem before, however, that time I was migrating a postgres from a region to another region and thought that was the cause to this but since I haven't touched the db in that way this time I have literally no idea.
Deploy logs:2025-11-26T15:26:16.000000000Z [inf] Starting Container 2025-11-26T15:26:17.395204416Z
[err] ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-10.23.0.tgz 2025-11-26T15:26:20.617740994Z [err] 2025-11-26T15:26:20.617816221Z
[inf] Prisma DATABASE_URL: postgresql://postgres:LMamCWQlskZqNCoHyRsHHpvRGcQOeMMK@postgres-dob5.railway.internal:5432/railway 2025-11-26T15:26:20.617823882Z
[err] Loaded Prisma config from prisma.config.ts. 2025-11-26T15:26:21.591211805Z
[inf] Prisma schema loaded from prisma/models 2025-11-26T15:26:21.591218500Z
[inf] Datasource "db": PostgreSQL database "railway", schema "public" at "postgres-dob5.railway.internal:5432" 2025-11-26T15:26:26.585652303Z
[inf] 2025-11-26T15:26:26.585658906Z
[err] Error: P1001: Can't reach database server at postgres-dob5.railway.internal:5432 2025-11-26T15:26:26.585665348Z [err] 2025-11-26T15:26:26.585673145Z
[err] Please make sure your database server is running at postgres-dob5.railway.internal:5432. 2025-11-26T15:26:33.000000000Z
[inf] Stopping Container
4 Replies
3 months ago
Hey there! We've found the following might help you get unblocked faster:
🧵 Changed region of postgres db and now DATABASE_URL seems FUBAR
🧵 P1001: Can't reach database server at
postgres.railway.internal:5432
If you find the answer from one of these, please let us know by solving the thread!
3 months ago
The first post the bot responded with was the one I was making the other day: https://station.railway.com/questions/changed-region-of-postgres-db-and-now-da-1fb87d8e I closed that post since I had to create a completely new database for it to work, but I don't want to do it now since I don't want to loose my data and it could very much happen again.
3 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 3 months ago
3 months ago
One thing I've checked is that I'm not trying to connect to the db during the Build phase, which according to the docs can't access things on the private network. But I think I'm in the deploy phase(if that's even a phase), because that's where the problem occurs. This is my railway.json:
{
"$schema": "https://railway.com/railway.schema.json",
"build": {
"builder": "DOCKERFILE",
"dockerfilePath": "apps/backend/Dockerfile"
},
"deploy": {
"startCommand": "node dist/main.js",
"preDeployCommand": ["pnpm prisma migrate deploy"],
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10,
"healthcheckPath": "/health",
"healthcheckTimeout": 100
}
}
3 months ago
I added this to the connection url connect_timeout=500. My pre deploy command now takes five minutes which is unacceptable but I hope Railway can look into this matter more.
Status changed to Solved brody • 3 months ago