Cannot connect to Postgres
borislavjjordanov-hash
HOBBYOP

a month ago

Hi,

My Node.js backend (invoice-app) cannot connect to the Postgres service in the same Railway project. Here's what I've diagnosed:

Internal network:

getent hosts postgres.railway.internal returns only IPv6: fd12:33e:5e40:1:5000:d1:f07b:21f3

IPv4: (none) — no IPv4 address is assigned

Connecting to the IPv6 address times out — the container has no IPv6 connectivity despite Private Networking showing "IPv4 & IPv6"

Public URL (switchyard.proxy.rlwy.net:46889):

TCP connects successfully (curl -v telnet:// shows "Connected")

TLS handshake starts but hangs indefinitely — never completes

Node.js pg returns ECONNRESET immediately

What I've tried:

ssl: { rejectUnauthorized: false }

NODE_TLS_REJECT_UNAUTHORIZED=0

Direct IPv6 address with family: 6

Direct IP 66.33.22.232 with SSL

dns.setDefaultResultOrder('ipv4first')

Redeploying both services

Result: The app starts (Server running on port 8080) but every pool.query() fails, making login return 500.

The Postgres service itself is healthy — backups run successfully using the same public URL via pg_dump.

Please advise how to restore connectivity between these two services.

Solved$10 Bounty

0 Replies

Railway
BOT

a month ago

This thread has been opened as a bounty so the community can help solve it.

Status changed to Open Railway about 1 month ago


Status changed to Solved borislavjjordanov-hash about 1 month ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...