My database service is running but my backend is connected
manishgotame
PROOP

2 months ago

My database service is running and I have connected the database to my backend. I have used all the possible urls and port, public and internal and I am still getting the error below. what's the cause?

From the log explorer

return func(*args, **kwargs)

File "/opt/venv/lib/python3.10/site-packages/django/db/backends/postgresql/base.py", line 277, in get_new_connection

connection = self.Database.connect(**conn_params)

File "/opt/venv/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect

conn = connect(dsn, connectionfactory=connection_factory, **kwasync)

django.db.utils.OperationalError: connection to server at "viaduct.proxy.rlwy.net" (66.33.22.243), port 5432 failed: Connection timed out

Is the server running on that host and accepting TCP/IP connections?

Solved

1 Replies

sarahkb125
EMPLOYEE

2 months ago

Hi there,

Looking at your error, you're connecting to viaduct.proxy.rlwy.net on port 5432 — that's the public proxy hostname, but port 5432 is the default Postgres port, not your actual public proxy port. The public proxy uses a randomly assigned port (usually something like 12345, 54321, etc.), not 5432.

Check your database service's variables and look for PGPORT or the port in your DATABASE_PUBLIC_URL. You'll want to use that specific port number, not 5432.

Even better, since both services are on Railway, you should use the private network instead — it's faster and doesn't incur egress charges. Use PGHOST_PRIVATE and PGPORT_PRIVATE (which is 5432 on private networking), or just reference DATABASE_PRIVATE_URL directly in your Django settings.

Best,

The Railway Team


Status changed to Awaiting User Response Railway about 2 months ago


Status changed to Solved sarahkb125 about 2 months ago


Loading...