3 months ago
I am attempting to connect a PayloadCMS GitHub Repo to a MongoDB instance both hosted on Railway. However, I am unable to make a connection using the private address generated by railway ${{ MongoDB.MONGO_URL }} and receive the below error message:
Error: cannot connect to MongoDB. Details: getaddrinfo ENOTFOUND mongodb.railway.internal
This implies that the error is related to the connection string, however, when I attempt to make a connection to the MongoDB instance using the public address and Mongo Compass the connection is successful. More bizarrely if I try to connect to an Atlas Cluster using the same source repo in Railway the connection is also successful.
I am happy to use an Atlas Cluster but I would prefer to host everything on Railway but need to be able to connect to the MongoDB instance via the private address.
3 Replies
3 months ago
Hi there, could you make sure your app service has the correct reference variables for your MongoDB db setup? Our docs on connecting to Mongo might help https://docs.railway.com/guides/mongodb#connect
Status changed to Awaiting User Response railway[bot] • 3 months ago
3 months ago
Hi, thank you for your reply.
The connection string produced by the reference variables are below:
Internal
mongodb://username:password@fray-cms-storage.railway.internal:27017
External
mongodb://username:password@yamabiko.proxy.rlwy.net:34692
I can connect to the railway MongoDB instance using the external address on my local machine (using the same repo).
I can also connect to an Atlas cluster on railway (using the same repo).
But I cannot connect the railway MongoDB instance using the internal address on railway (using the same repo).
Is there something I can do to fix this?
Status changed to Awaiting Railway Response railway[bot] • 3 months ago
3 months ago
Hey, is your app correctly using our private network? I'd recommend checking out our docs on https://docs.railway.com/guides/mongodb and https://docs.railway.com/guides/private-networking in case you might have something misconfigured
Status changed to Awaiting User Response railway[bot] • 3 months ago