23 days ago
I'm seeing ~150ms latency on every single Postgres query, including a bare SELECT 1 on a warm, pooled connection over internal networking (postgres.railway.internal).
Diagnostic results from app startup:
pg.Pool Query 1 (cold): 1052ms | Query 2 (warm): 153ms | Query 3 (warm): 152ms
postgres.js Query 1 (cold): 1238ms | Query 2 (warm): 152ms | Query 3 (warm): 152ms
What I've confirmed:
- DNS resolves correctly: postgres.railway.internal -> fd12:cfd0:b7bb:1:1000:3b:3e5e:dd39
- SSL is disabled (not needed on internal network)
- Connection pooling is working (pool shows idle connections being reused)
- Postgres CPU and memory are well within limits (near 0 CPU, ~100-150MB RAM)
- No PG* environment variable interference - everything uses DATABASE_URL with the internal hostname
- Restarting the Postgres service did not change the latency
- The same setup on my staging environment gets 2-6ms per warm query
This 150ms floor means every API request takes 1-2+ seconds because auth middleware alone runs 3-4 sequential queries. The app is unusable at this speed.
Is it possible that the Postgres container and the app container are scheduled on different physical nodes? Could you look into whether they can be co-located? Any other suggestions for getting this latency down to what I'm seeing on staging (<10ms)?
Happy to provide any additional logs or diagnostics.
Pinned Solution
23 days ago
Did you maybe accidentally put the database in another region?
150ms is not a same Datacenter different nodes latency.
2 Replies
23 days ago
Did you maybe accidentally put the database in another region?
150ms is not a same Datacenter different nodes latency.
lu4p
Did you maybe accidentally put the database in another region?150ms is not a same Datacenter different nodes latency.
23 days ago
Yep that was the issue haha, thanks! 
Status changed to Solved brody • 23 days ago