PostgreSQL Private Connection Not Resolving (RAILWAY_PRIVATE_DOMAIN Fails with NXDOMAIN)
briankim0828
TRIALOP

a year 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 Projectwhite_check_mark emoji

2. Checked That PostgreSQL Plugin Is Runningwhite_check_mark emoji

3. Restarted PostgreSQL Plugin and Bot Deploymentwhite_check_mark emoji

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

• Output: apex-manager.railway.internal

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

• 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 Domainx emoji(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

brody
EMPLOYEE

a year 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 11 months ago


Status changed to Solved brody 11 months ago


Loading...