Can't connect to mongo DB from Node JS server
guyyt
HOBBYOP

2 months ago

hi

I keep getting error in connecting to my mongoDB cluster from NodeJS server.

it used to work well for 2 years, and with nothing changed it started failing almost all the time, making my service unavailable

error:

[MongoDB] Connection failed: MongoServerSelectionError: getaddrinfo ENOTFOUND ac-olibm3r-shard-00-00.cuhp6kd.mongodb.net

at Topology.selectServer (/app/node_modules/mongodb/src/sdam/topology.ts:624:30)

at async Topology._connect (/app/node_modules/mongodb/src/sdam/topology.ts:470:22)

at async Topology.connect (/app/node_modules/mongodb/src/sdam/topology.ts:407:7)

at async topologyConnect (/app/node_modules/mongodb/src/mongo_client.ts:610:9)

at async MongoClient._connect (/app/node_modules/mongodb/src/mongo_client.ts:622:7)

at async MongoClient.connect (/app/node_modules/mongodb/src/mongo_client.ts:534:7) {

reason: TopologyDescription {

type: 'ReplicaSetNoPrimary',

It is pure DNS resolution failure from Railway → MongoDB Atlas

$10 Bounty

11 Replies

Railway
BOT

2 months ago

Your service logs show repeated ENOTFOUND errors for ac-olibm3r-shard-00-00.cuhp6kd.mongodb.net, which is a DNS resolution failure. We traced the DNS chain for that hostname and it ultimately resolves to an AWS EC2 address that returns no A/AAAA records from the public internet, meaning the issue is with your MongoDB Atlas cluster's DNS, not with our platform. We recommend checking the status of your cluster in the MongoDB Atlas dashboard to ensure it hasn't been paused, terminated, or migrated to a new hostname.


Status changed to Awaiting User Response Railway 2 months ago


Status changed to Awaiting Railway Response Railway 2 months ago


guyyt
HOBBYOP

2 months ago

my cluster is working fine, and connecting to it from my PC works well


guyyt

my cluster is working fine, and connecting to it from my PC works well

guyyt
HOBBYOP

2 months ago

this call from Nodejs server deployed to Railway is not working from my project:

nslookup ac-olibm3r-shard-00-00.cuhp6kd.mongodb.net


Railway

Your service logs show repeated `ENOTFOUND` errors for `ac-olibm3r-shard-00-00.cuhp6kd.mongodb.net`, which is a DNS resolution failure. We traced the DNS chain for that hostname and it ultimately resolves to an AWS EC2 address that returns no A/AAAA records from the public internet, meaning the issue is with your MongoDB Atlas cluster's DNS, not with our platform. We recommend checking the status of your cluster in the MongoDB Atlas dashboard to ensure it hasn't been paused, terminated, or migrated to a new hostname.

heran-jn
PRO

2 months ago

Hello,

I’m experiencing the same issue. DNS resolution is failing (ENOTFOUND) for ac-mvn5kly-shard-00-0{0,1,2}.pgawsr9.mongodb.net, specifically ac-mvn5kly-shard-00-00.pgawsr9.mongodb.net.

I’m able to access the cluster locally, via MongoDB Compass, and directly through MongoDB without any problems. The DNS issue only occurs on Railway. Could you please advise?


guyyt
HOBBYOP

2 months ago

I will mention that now its working again

but this is not the first time its happening, and its crashing our service

and it would probably happen again


Status changed to Solved jake 2 months ago


guyyt
HOBBYOP

2 months ago

sorry this is not solved

how can we make sure it does not happen again?


Status changed to Awaiting Railway Response Railway 2 months ago


Status changed to Open Railway 2 months ago


domehane
FREE

2 months ago

Hello, so the dns for your cluster returns zero records from the public internet, meaning the issue is definitely on atlas's side not railway's. just log into your mongodb atlas dashboard and check if your cluster is paused, terminated, or got a new hostname, one of those three is almost certainly the culprit. resume it if paused and you should be good


domehane
FREE

2 months ago

one thing to note since it fails "almost all the time" and not always, your cluster isn't fully terminated, something still responds occasionally. so just check your atlas dashboard for a paused cluster or a hostname change, one of those two is your issue

Hope this help you :)


domehane

one thing to note since it fails "almost all the time" and not always, your cluster isn't fully terminated, something still responds occasionally. so just check your atlas dashboard for a paused cluster or a hostname change, one of those two is your issue Hope this help you :)

guyyt
HOBBYOP

2 months ago

its probably not Atlas, since on local PC my server connecter to Mongo without problems


heran-jn
PRO

2 months ago

During debugging, I observed that the DNS resolution chain points to an AWS instance in the me-south-1 (Middle East – Bahrain) region, which is currently experiencing infrastructure issues. These appear to be caused by underlying AWS failures rather than MongoDB itself.

As a result, shards hosted in this region, such as ac-mvn5kly-shard-00-00.pgawsr9.mongodb.net may become unreachable or unstable.

AWS outages are often region or Availability Zone–specific, and MongoDB Atlas nodes are physically tied to those regions. Because of this, different clients (e.g., local environments vs. Railway) may:

  • Resolve to different DNS endpoints
  • Route through different network paths
  • Connect to different IPs or replicas

This explains why:

  • A local machine may connect via a healthy path or replica
  • Railway may route to an affected zone or failing node

Access to a MongoDB shard can vary depending on the client’s region and network path. During regional AWS outages (such as in me-south-1), some environments may fail to resolve or reach the shard, while others may continue to work.

From my understanding, it depends on AWS regional availability. I would appreciate any advice or recommendations on how to avoid this in the future.

I hope this helps


guyyt
HOBBYOP

2 months ago

please note the same is happening now


Welcome!

Sign in to your Railway account to join the conversation.

Loading...