4 months ago
Attempting to use private networking for my API/Worker to access the Postgres and Redis instances - however can't get these to resolve the hostname.
ECONNECT timeouts on Redis, postgres not working with/without SSL.
Using the public URL is working fine, however I'm getting charged in excess of $500 a month for this - so it'd be great to utilise internal networking!
Pinned Solution
4 months ago
Hey, can you provide a bit more info on the stack you're using. Language? Libraries being used to connect to the postgres/redis? That would help me diagnose the issue.
That said, based on the railway documentation, I found some documented "known" issues with both PostgreSQL and Redis to reference.
Redis Connection Issues (ECONNECT timeouts)
The most common cause for this is that ioredis requires special configuration for IPv6.
Railway's private network is IPv6 forward (it does support IPv4, but only in newly created environments after October 16th), and by default, ioredis only does IPv4 (A record) lookups.
Solution: Add family=0 to enable dual-stack lookup:
import Redis from "ioredis";
const redis = new Redis(process.env.REDIS_URL + "?family=0");
const ping = await redis.ping();Postgres Connection Issues
Make sure that you're using the internal hostname format:
postgresql://postgres:password@postgres.railway.internal:5432/railwaySSL might (?) cause issues over private networking iirc. I'd try disabling that first to test if you can get a connection, then setup SSL separately.
Documentation References
2 Replies
4 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
4 months ago
Hey, can you provide a bit more info on the stack you're using. Language? Libraries being used to connect to the postgres/redis? That would help me diagnose the issue.
That said, based on the railway documentation, I found some documented "known" issues with both PostgreSQL and Redis to reference.
Redis Connection Issues (ECONNECT timeouts)
The most common cause for this is that ioredis requires special configuration for IPv6.
Railway's private network is IPv6 forward (it does support IPv4, but only in newly created environments after October 16th), and by default, ioredis only does IPv4 (A record) lookups.
Solution: Add family=0 to enable dual-stack lookup:
import Redis from "ioredis";
const redis = new Redis(process.env.REDIS_URL + "?family=0");
const ping = await redis.ping();Postgres Connection Issues
Make sure that you're using the internal hostname format:
postgresql://postgres:password@postgres.railway.internal:5432/railwaySSL might (?) cause issues over private networking iirc. I'd try disabling that first to test if you can get a connection, then setup SSL separately.
Documentation References
Status changed to Solved brody • 3 months ago