Error: getaddrinfo ENOTFOUND postgres.railway.internal

I'm trying to connect a node app to a postgresql database (both are in the same railway project) through the private network so I'm using the DATABASE_PRIVATE_URL in my node app, but then I get this error in the logs Error: getaddrinfo ENOTFOUND postgres.railway.internal. Before I was connecting my node app to my postgresql database through the public url (so using DATABASE_URL env variable) and all was going fine, but then I realized the higher costs this public connection implies (rookie mistake) so I changed it to the private network however now I have this issue.
Solution:
then have a look at this docs section https://docs.railway.app/guides/private-networking#workaround-for-alpine-based-images the 3 second sleep is still needed though...
Jump to solution
26 Replies
Percy
Percy11mo ago
Project ID: 93ff8b35-df80-4f04-9f54-b6e4fa647fbf
Ghost Order
Ghost OrderOP11mo ago
93ff8b35-df80-4f04-9f54-b6e4fa647fbf
Brody
Brody11mo ago
add a 3 second sleep to the beginning of your start script
Ghost Order
Ghost OrderOP11mo ago
gotcha, let me try it still is giving the same error
Brody
Brody11mo ago
can you show me how you have implemented the suggested change?
Ghost Order
Ghost OrderOP11mo ago
sure, I just added "sleep 4 && <the rest of the start script>" the start script indeed is delayed by 4 secs
Brody
Brody11mo ago
can you show me a screenshot of your railway project
Ghost Order
Ghost OrderOP11mo ago
you mean the project page? where all the services are
Brody
Brody11mo ago
are you deploying this with nixpacks or a dockerfile?
Medim
Medim11mo ago
Are you using Payload CMS?
Ghost Order
Ghost OrderOP11mo ago
dockerfile yes
Brody
Brody11mo ago
does your dockerfile use an alpine based image?
Ghost Order
Ghost OrderOP11mo ago
yep node:18.8-alpine
Solution
Brody
Brody11mo ago
then have a look at this docs section https://docs.railway.app/guides/private-networking#workaround-for-alpine-based-images the 3 second sleep is still needed though
Ghost Order
Ghost OrderOP11mo ago
ok Ill check it thank you @Brody I added the ENABLE_ALPINE_PRIVATE_NETWORKING=true metioned in the docs and now my app is working fine
Brody
Brody11mo ago
awsome
Alex / KATT 🐱
this is an issue for me after seemingly trying everything here - added a 10s timeout before start on my service - added ENABLE_ALPINE_PRIVATE_NETWORKING=true in the service using it + redis schema:
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "echo \"no-build\""
},
"deploy": {
"numReplicas": 1,
"startCommand": "sleep 10 && cd apps/xxxx && pnpm tsx server",
"healthcheckPath": "/",
"sleepApplication": true,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "echo \"no-build\""
},
"deploy": {
"numReplicas": 1,
"startCommand": "sleep 10 && cd apps/xxxx && pnpm tsx server",
"healthcheckPath": "/",
"sleepApplication": true,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
No description
No description
No description
Alex / KATT 🐱
Error: getaddrinfo ENOTFOUND xxx-redis.railway.internal
Error: getaddrinfo ENOTFOUND xxx-redis.railway.internal
i might add that it adds if i use the public url of redis instead
Alex / KATT 🐱
and that it's referenced throguh a variable, i haven't hard-coded it
No description
Brody
Brody8mo ago
ioredis?
Alex / KATT 🐱
yup
Brody
Brody8mo ago
please read the docs page for that - https://docs.railway.app/guides/private-networking#known-configuration-requirements-for-ipv6 you aren't using alpine, so I'm not sure why you set that variable, and I'm really not sure why you set it on the redis service
Alex / KATT 🐱
A web application that makes client-side requests cannot communicate to another service over the private network.
are you saying that because my app is public, it can't connect to redis over the public network?
Brody
Brody8mo ago
bro click the little button that says ioredis
Alex / KATT 🐱
oops, i am a moron thank you so much, setting my REDIS_URL to the below does indeed work
${{redis.REDIS_PRIVATE_URL}}?family=0`
${{redis.REDIS_PRIVATE_URL}}?family=0`
apologies for not being able to RTFM, i was blind
Brody
Brody8mo ago
no worries
Want results from more Discord servers?
Add your server