Database connection randomly fails after months of working fine - Dashboard gets stuck on "Database Connection"
juanmorenodecimetrix
PROOP

19 days ago

Hi everyone,

I'm experiencing a recurring issue with my PostgreSQL database on Railway and I'd like to understand what's happening.

The problem:

My database has been working perfectly for months

Suddenly, without any changes from my side, the connection fails

  • In the Railway dashboard, the "Database Connection: We are unable to connect to the database via SSH." widget keeps reloading, displays the SSH error, and reloads again... and so on

My deployed application also stops responding because it can't reach the database

After some time (5 MIN), it started work again on its own

What I've ruled out:

  1. It's not an SSH issue (I'm not using SSH)
  2. My environment variables haven't changed
  3. The database service appears to be "online" in the dashboard
  4. Other users have reported identical symptoms (I've seen several posts about the postgres.railway.internal private network hanging while localhost works fine), But the ticket related to this was marked as completed.

What I've trie:

  1. Restarting the PostgreSQL service It worked after I redeployed Postgres, but it took quite a while.
  2. Redeploying my application (sometimes works)

My questions:

  1. Is this a known issue with Railway's internal private network?
  • although, I tried to connect to Postgres via the public network using DBeaver, but I couldn't connect either.
  1. Why does the dashboard's "Database Connection" get stuck when this happens?
  2. Is there any configuration I should check to prevent this?

Does Railway have an official status page for these intermittent connectivity issues?

My current configuration:

  • DATABASE_PRIVATE_URL="postgresql://${{POSTGRES_USER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:5432/${{POSTGRES_DB}}"
  • DATABASE_URL="postgresql://${{POSTGRES_USER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:${{RAILWAY_TCP_PROXY_PORT}}/${{POSTGRES_DB}}"
  • NO_TS_TUNE="true"
  • PGDATA="/var/lib/postgresql/data/pgdata"
  • PGDATABASE="${{POSTGRES_DB}}"
  • PGHOST="${{RAILWAY_PRIVATE_DOMAIN}}"
  • PGPASSWORD="${{POSTGRES_PASSWORD}}"
  • PGPORT="${{RAILWAY_TCP_PROXY_PORT}}"
  • PGUSER="${{POSTGRES_USER}}"
  • POSTGRES_DB="railway"
  • POSTGRES_PASSWORD="****"
  • POSTGRES_USER="****"
  • RAILWAY_RUN_UID="0"
  • SSL_CERT_DAYS="820"

Any insights would be greatly appreciated.

Thanks in advance.

Solved

1 Replies

Status changed to Awaiting Railway Response Railway 19 days ago


chandrika
EMPLOYEE

19 days ago

Platform networking changes can occasionally cause existing database services to become temporarily unreachable, even though the service appears healthy and online in the dashboard. The dashboard's "Database Connection" widget uses the same internal connectivity path, so it gets stuck in a reload loop during these events and redeploying the Postgres service helps, which you've already done.

One thing worth correcting in your configuration: your DATABASE_URL currently references RAILWAY_PRIVATE_DOMAIN, which is the internal hostname. If you need external access (e.g. from DBeaver), DATABASE_URL should use the public TCP proxy host and RAILWAY_TCP_PROXY_PORT instead. Your DATABASE_PRIVATE_URL is set up correctly for service-to-service communication within the project.


Status changed to Awaiting User Response Railway 19 days ago


Railway
BOT

12 days ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway 12 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...