8 hours ago
PostgreSQL TCP Proxy Accepts Connections but SSL Negotiation Times Out
Environment
- Environment: production
- Service: Postgres
- PostgreSQL version: 18
- TCP proxy destination port: 5432
- Railway CLI version: 5.75.0
- Latest deployment status: SUCCESS
- Client environment: macOS
Issue
The existing PostgreSQL service is inaccessible through its public TCP proxy.
DNS resolution and TCP connection establishment succeed, but PostgreSQL SSL negotiation never completes.
The application previously connected successfully using the same database configuration.
Diagnostic Results
| Check | Result |
|---|---|
| DNS resolution | Successful |
| TCP connection | Successful, approximately 252 ms |
| Railway TCP ingress logs | Connections recorded |
| PostgreSQL SSLRequest | No response within 5.5 seconds |
| psql | Connection timed out after approximately 6.3 seconds |
| Prisma | Unable to establish a database connection |
| Standard and direct TLS negotiation | Both failed |
| CPU and memory utilization | Low during the sampled diagnostic window |
| Deployment status | SUCCESS |
Earlier PostgreSQL deployment logs also contain TLS handshake errors reporting unexpected eof while reading.
Relevant Ingress Events
November 25, 2026:
- 05:17:35.540 UTC
- 05:17:35.612 UTC
Both connections were recorded by the public TCP proxy.
No corresponding PostgreSQL deployment log entries were observed within the same diagnostic window.
Requested Investigation
Could the Railway engineering team investigate the following?
- Whether the TCP proxy successfully forwarded both connections to the existing PostgreSQL deployment on port 5432.
- Whether PostgreSQL received the 8-byte PostgreSQL SSLRequest.
- Whether PostgreSQL returned an SSL negotiation response to the proxy.
- Whether the response was successfully forwarded to the external client.
- Whether the PostgreSQL listener, internal networking, or proxy backend routing is experiencing an issue.
- Whether connection exhaustion or another internal service condition could explain the observed behavior.
Please recommend a non-destructive recovery procedure based on the investigation.
This database contains existing production financial records. We have a verified encrypted backup, but would prefer to avoid restarting, redeploying, replacing the proxy, or modifying the database configuration unless supported by diagnostic evidence.
Thank you.
1 Reply
8 hours ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • about 8 hours ago
34 minutes ago
One PostgreSQL wire-protocol detail narrows this down:
Zero bytes after an 8-byte SSLRequest proves the stall happens before TLS starts. In ProcessStartupPacket, Postgres replies with one byte ('S'/'N') before checking certs, TLS, or pg_hba.conf. Even a broken cert or max_connections exhaustion normally responds (FATAL: sorry, too many clients already) and logs—not 5.5s of silence with zero logs.
With a ~252ms TCP handshake, logged ingress, low CPU/RAM, and zero Postgres logs at 05:17:35 UTC, four mechanisms fit:
- Public TCP proxy blackhole: Edge completes TCP and logs ingress, but bytes never reach port
5432(or replies drop). postmasterinDstate (volume I/O wait) or not callingaccept(): Low CPU/RAM, zero logs, unread sockets in accept queue.log_hostname = on+ stalled reverse DNS: PTR lookup runs inBackendInitialize()beforeSSLRequest, hanging silently.- External network drop (if both
psqland Prisma use the same external network).
4 Quick Questions
- Where does Prisma run? Same Railway project (
*.railway.internalvs.DATABASE_PUBLIC_URL) or external/local? - In the
05:17:35.540/.612 UTCingress logs, are any upstream bytes transferred, or only client close after ~5.5–6.3s? - When was the latest
SUCCESSdeploy vs. the last working connection, and is App Sleeping/Serverless off? - Did the public proxy fail from another network (e.g., hotspot), and does a dummy
sslmode=disableprobe (fake user) also hang silently?
Read-Only, Zero-Restart Isolation (Q1, Q2, Q5 & Q6)
Only Railway engineering can trace edge proxy internals, but you can prove inside the container whether packets reach 5432—read-only, no restart, redeploy, or config edits.
Run railway ssh (select Postgres / production):
1. Test Postgres & local TLS inside the container
pg_isready -h 127.0.0.1 -p 5432 -t 5
PGPASSWORD="${PGPASSWORD:-$POSTGRES_PASSWORD}" psql "host=127.0.0.1 port=5432 dbname=${PGDATABASE:-${POSTGRES_DB:-postgres}} user=${PGUSER:-${POSTGRES_USER:-postgres}} sslmode=require connect_timeout=5" -c "SELECT now();"- Succeeds: Postgres 18, SSL, and listener are healthy. Hangs: Internal fault (Checks 3–4).
2. Verify whether public proxy packets reach 5432
Reads /proc/net/tcp* directly (no extra tools; hex 1538 = 5432):
# Start this 15s watch, then run ONE psql probe from macOS via the public proxy
for i in $(seq 1 15); do date -u +%H:%M:%S; grep -i ':1538 ' /proc/net/tcp /proc/net/tcp6 2>/dev/null; sleep 1; done- Col 4 (
st):0A=LISTEN,01=ESTABLISHED,03=SYN_RECV. Col 5: growingrx_queueon0A=postmasternot accepting. - No new
01/03row on:1538: Proof the proxy accepted the socket at the edge without forwarding it. - New
01row appears whilepsqlhangs: Packets reached the container (backend hang or return-path drop).
3. Check config, log_hostname, and active waits
PGPASSWORD="${PGPASSWORD:-$POSTGRES_PASSWORD}" psql -U "${PGUSER:-${POSTGRES_USER:-postgres}}" -d "${PGDATABASE:-${POSTGRES_DB:-postgres}}" -c "SHOW listen_addresses; SHOW port; SHOW ssl; SHOW max_connections; SHOW log_hostname; SELECT state, wait_event_type, wait_event, count(*) FROM pg_stat_activity GROUP BY 1,2,3 ORDER BY 4 DESC;"4. Check disk/SHM & D-state processes
df -h
ps -eo pid,stat,args 2>/dev/null || psLook for D in STAT on postgres processes, or a 100% full $PGDATA / /dev/shm.
Non-Destructive Recovery
- Check 1 passes + Check 2 shows zero
:1538sockets (Proxy Routing Stall):- Postgres and your data are intact.
- Zero-restart workaround (Railway apps): Point Prisma to Railway's private network (
postgres.railway.internal:5432/RAILWAY_PRIVATE_DOMAIN). - Caution on recreating the proxy: Editing it changes
RAILWAY_TCP_PROXY_*vars and usually triggers a redeploy/restart. To keep zero restarts, post Checks 1–2 so Railway engineering can fix the stale proxy route directly.
- Check 1 hangs or Checks 3–4 show
D-state /rx_queue/log_hostname:- If the Unix socket responds, kill only stuck PIDs (
SELECT pg_terminate_backend(pid);) instead of restarting. - If
postmasteris inD-state, sharepsanddf -hwith Railway engineering first to verify volume health.
- If the Unix socket responds, kill only stuck PIDs (
Post Checks 1–4 and the 4 answers above to isolate the exact failure layer safely.