Skip to content
Connection Issue to PostgreSQL via Private Network (postgres.railway.internal)
slabuzov
OP

a year ago

Hello Railway Support Team,

I am having trouble connecting my Spring Boot application to PostgreSQL (postgres-oqtm) via the private network.

-- connection config
spring:
  datasource:
    url: jdbc:postgresql://${HOST}:{PORT}/${DB}
    username: ${USER}
    password: ${PASSWORD}
    driver-class-name: org.postgresql.Driver


✅ Connection WORKS with: HOST and PORT from DATABASE_PUBLIC_URL
❌ Connection FAILS with: HOST=postgres-oqtm.railway.internal and PORT=5432

Error: PSQLException: The connection attempt failed.

Both services are in the same Railway project. Public connection works fine, but private network connection fails.

Questions:
1. Is postgres-oqtm.railway.internal:5432 the correct internal endpoint?
2. Any additional configuration needed for private network connectivity?


Thanks for your help.
Solved$10 Bounty

8 Replies

Railway
BOT

a year ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


Status changed to Awaiting Conductor Response ray-chen • 12 months ago


Railway

Hey there! We've found the following might help you get unblocked faster: - [🧵 PostgreSQL Private Network Unreachable After Upgrade to Pro Plan](https://station.railway.com/questions/postgre-sql-private-network-unreachable-a-bc53282c) - [🧵 Prisma deployment fails using internal Postgres URI](https://station.railway.com/questions/prisma-deployment-fails-using-internal-p-9a474cc7) - [🧵 Cannot connect to postgres database](https://station.railway.com/questions/cannot-connect-to-postgres-database-cbc3326f) If you find the answer from one of these, please let us know by solving the thread!

slabuzov
OP

a year ago

I've carefully reviewed the provided links/documentation, but unfortunately, I haven't found a solution to my specific issue.


badrlaajali

a year ago

Same issue for me :

Error: P1001: Can't reach database server at postgres.railway.internal:5432 Please make sure your database server is running at postgres.railway.internal:5432.

Any solution ?


a year ago

Hey, are you guys still having this issue?


Status changed to Awaiting User Response Railway • 12 months ago


medim

Hey, are you guys still having this issue?

slabuzov
OP

a year ago

Yes


apotapov

a year ago

Me and a friend (also a railway project) are having this same issue.

```

Datasource "db": PostgreSQL database "railway", schema "public" at "postgres.railway.internal:5432"

Error: P1001: Can't reach database server at postgres.railway.internal:5432

Please make sure your database server is running at postgres.railway.internal:5432.

```

Works fine from DATABASE_PUBLIC_URL. Fails from DATABASE_URL. I've been battling this for a week now. Even deleted and created a brand new project. The issue persists, I'm completely blocked from deploying. One of my existing railway projects works fine with the private DB URL.

Any newly created projects have issues. NextJS + Prisma.


fuelpass-ingo

a year ago

Hi all, is there a solution we are facing the same issue. Sometimes it work sometime the connection and deployment fails. We debug our application and couldn't find any issues in our code. It looks to us that everything works fine when using the external url to connect.


slabuzov
OP

a year ago

Hello Railway Support Team,

I'm happy to report that the private network connection issue has been resolved in my case. My Spring Boot application can now successfully connect to PostgreSQL via postgres.railway.internal:5432.

Thank you for your assistance with this matter. I'm marking this ticket as solved.


Status changed to Solved slabuzov • 11 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...