socket.gaierrordespite correct configuration
a month ago
Hello Railway Support Team,
I need help troubleshooting a private DNS resolution issue between my Python Telegram bot and PostgreSQL.
Services:
- Bot service:
franchise_qualifier - Database service:
Postgres - Both services are in the same Railway project and the same
productionenvironment. - PostgreSQL Private Networking shows “Ready to talk privately”.
Problem:
The bot starts successfully, but every database operation fails with:
socket.gaierror: [Errno -2] Name or service not known
I initially used postgres.railway.internal. I then renamed the private domain to franchise-db.railway.internal, updated DATABASE_URL, and redeployed the bot. The DNS resolution error persists.
The application uses port 5432. The PostgreSQL service is running, and Railway shows private networking as ready.
Could you please investigate why the bot container cannot resolve the PostgreSQL private hostname? This may be a private DNS or service networking issue.
I can provide project, environment, and service IDs privately if needed.
Thank you.
1 Reply
a month ago
Your bot can't resolve the database hostname because the two services are in separate projects: franchise_qualifier is in one project and Postgres is in another. Private networks are isolated by project and environment, so a .railway.internal hostname only resolves for services in the same project and the same environment.
To connect over the private hostname, the database needs to be in the same project and environment as the bot.
Status changed to Awaiting User Response Railway • about 1 month ago
24 days ago
This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!
Status changed to Solved Railway • 24 days ago