PostgreSQL Private Connection Not Resolving (RAILWAY_PRIVATE_DOMAIN Fails with NXDOMAIN)

briankim0828
TRIAL

9 months ago

I am trying to connect my Railway-deployed Discord bot to my PostgreSQL database using private networking (RAILWAY_PRIVATE_DOMAIN). However, the bot is unable to resolve the private hostname and fails to connect.

Project Setup:

• The bot service and PostgreSQL plugin are in the same Railway project.

• Environment variables are correctly set in Railway:

PGHOST=${{RAILWAY_PRIVATE_DOMAIN}}

PGPORT=5432

PGUSER=postgres

PGPASSWORD=<hidden>

PGDATABASE=railway

• PostgreSQL plugin is running and has been restarted multiple times.

Error When Running in Railway Logs:
Error fetching members: Error: connect ECONNREFUSED fd12:69da:fa88:0:2000:9:a221:8e10:5432
• This suggests that the bot cannot reach the database via private networking.

Error When Running nslookup Inside Railway Shell:
nslookup apex-manager.railway.internal

Server: 210.220.163.82

Address: 210.220.163.82#53

** server can't find apex-manager.railway.internal: NXDOMAIN

• This indicates that Railway’s internal DNS is not resolving RAILWAY_PRIVATE_DOMAIN.

DEBUG STEPS TAKEN:
1. Verified Both Services Are in the Same Railway Project

2. Checked That PostgreSQL Plugin Is Running

3. Restarted PostgreSQL Plugin and Bot Deployment

4. Checked $RAILWAY_PRIVATE_DOMAIN in Railway Shell (echo $RAILWAY_PRIVATE_DOMAIN)

• Output: apex-manager.railway.internal

5. Tested Direct Connection with psql in Railway Shell (psql -h $PGHOST -U $PGUSER -d $PGDATABASE -p $PGPORT)

• psql: error: could not translate host name "apex-manager.railway.internal" to address: nodename nor servname provided, or not known

6. Attempted nslookup on Private Domain(failed with NXDOMAIN)

Please help me with:
• Why is RAILWAY_PRIVATE_DOMAIN not resolving inside Railway?

• Is there an issue with Railway’s internal DNS?

• How can I ensure that the bot can connect using private networking instead of the public TCP proxy?

Thank you so much, whoever might be able to help. I'm a bit of a beginner, so everything is much appreciated.

Solved

1 Replies

9 months ago

Hello,

> Why is RAILWAY_PRIVATE_DOMAIN not resolving inside Railway?

Because railway shell is not a shell inside Railway, it is a local shell.

> Is there an issue with Railway’s internal DNS?

Nope!

> How can I ensure that the bot can connect using private networking instead of the public TCP proxy?

Set the correct variables.

I have set the correct variables for you and your deployment is now online.

Best,
Brody


Status changed to Awaiting User Response Railway 9 months ago


Status changed to Solved brody 9 months ago