a year ago
Current setup:
API service using Dockerfile.staging
MongoDB service (fully managed by Railway)
Both services are in the same project
Public networking works fine with monorail.proxy.rlwy.net
Private networking fails with ENOTFOUND when using mongodb-woks.railway.internal
I've tried:
Using the RAILWAYPRIVATEDOMAIN
Setting up service dependencies
Ensuring both services have private networking enabled
Various MongoDB URI formats with the internal domain
Error received:
getaddrinfo ENOTFOUND mongodb-woks.railway.internal
Could you help me understand:
What's the correct configuration for private networking between services?
Are there specific requirements or steps I'm missing?
How can I debug private networking connectivity issues?
19 Replies
a year ago
are you trying to connect to mongo during build?
No, we're not trying to connect to MongoDB during build. The MongoDB connection only happens at runtime when the application starts. Our Dockerfile.staging shows a two-stage build process that only installs dependencies and builds TypeScript code, without any database connections during the build phase.
The connection issue occurs after deployment, when the running container tries to connect to MongoDB using the private network domain (mongodb-woks.railway.internal).
a year ago
can you please use a reference variable -
MONGODB_URI=${{MongoDB-WOKs.MONGO_URL}}/tabmedia_staging?authSource=adminerror: [Database] MongoDB connection error | error=getaddrinfo ENOTFOUND mongodb-woks.railway.internal {"timestamp":"2025-01-03T17:26:04.568Z"}
error: [Database] Full error object | error={
"message": "getaddrinfo ENOTFOUND mongodb-woks.railway.internal",
"reason": {
"type": "Unknown",
"servers": {
"mongodb-woks.railway.internal:27017": {
"address": "mongodb-woks.railway.internal:27017",
"type": "Unknown",
"hosts": [],
"passives": [],
"arbiters": [],
"tags": {},
"minWireVersion": 0,
"maxWireVersion": 0,
"roundTripTime": -1,
"minRoundTripTime": 0,
"lastUpdateTime": 1087871448,
"lastWriteDate": 0,
"error": {},
"topologyVersion": null,
"setName": null,
"setVersion": null,
"electionId": null,
"logicalSessionTimeoutMinutes": null,
"maxMessageSizeBytes": null,
"maxWriteBatchSize": null,
"maxBsonObjectSize": null,
"primary": null,
"me": null,
"$clusterTime": null
}
},
"stale": false,
"compatible": true,
"heartbeatFrequencyMS": 10000,
"localThresholdMS": 15,
"setName": null,
"maxElectionId": null,
"maxSetVersion": null,
"commonWireVersion": 0,
"logicalSessionTimeoutMinutes": null
}
} {"timestamp":"2025-01-03T17:26:04.578Z"}
error: [Database] Stack trace | stack=MongooseServerSelectionError: getaddrinfo ENOTFOUND mongodb-woks.railway.internal
at _handleConnectionErrors (/usr/src/app/node_modules/mongoose/lib/connection.js:909:11)
at NativeConnection.openUri (/usr/src/app/node_modules/mongoose/lib/connection.js:860:11) {"timestamp":"2025-01-03T17:26:04.580Z"}
Stopping Containera year ago
hmmm, not sure why you say that, your current variable is not the same as what i provided
I'm not using it now, I've switched over to using the public network because I couldn't get it working
a year ago
please use the reference variable i provided and then we can go from there
You're probably right, have been trying so many things I didn't notice you added the ?authSource_admin param at the end. I'll update my config with the provided reference variable now.
a year ago
not saying its going to magically work, but its best to start out with the correct variable first
a year ago
perhaps you have configured mongoose to do an ipv4 lookup instead of a dual stack lookup?
a year ago
yeah the private network is ipv6 only
a year ago
up and running?
a year ago
!s
Status changed to Solved brody • 11 months ago