Heroku and MongoDB Atlas connection failing

I’m following this tutorial here and having issues getting it work.

I’ve added a Heroku addon to get a static IP Address.
I’ve tried Fixie, Fixie Socks, now I’m using Quotaguard (each on results in same error).
I’m adding those static IPs to Atlas’s whitelisted IP addresses.

The Mongo connection URL is added as a Heroku env var.

new MongoNetworkError(
MongoNetworkError: failed to connect to server [cluster0-shard-00-01.0kdvb.mongodb.net:27017] on first connect [Error: write EPIPE

In localhost everything works (I’ve whitelisted my Macbooks IP address). But on Heroku it fails.

I know it is suggested to open the whitelist to ALL IP addresses. But that just is a terrible solution. There has to be a way to make this work.

Hi @George_N!

Thanks for posting your issue here (and on other related topics; I see ya!). I’m sorry to hear that this has been a persistent issue for you.

By chance, have you tried this possible solution from QuotaGuard’s documentation?

1 Like
  1. go to mongodb atlas
  2. click security → Network Access → ADD IP ADDRESS → Choose allow access from anywhere and save
  3. click connect and get your application to your code and paste to your application.
3 Likes

I also experienced the same issue. As the IP address is not whitelisted you can allow any IP.
For the production purpose that is not a good approach. You can do it by QuotaGuard Static. I didn’t try it. I just simply want to know how these stuffz works.

QuotaGuard Static does not work either. I tried it after having the same failures.

Thank you a lot!!!1

Hi, did you manage to get this sorted? I have the same problem.

I followed this tutorial:

It states to look up your mongoDB cluster shards at cluster’s shards here:
SRV Record Lookup - Check Service Record (SRV) DNS records for any domain.

here is one of my three shards (I can’t post more as I am a new user on this forum) came up with the following shards:

tcp://cluster0-shard-00-00.yk6dyto.mongodb.net:27017

I just can’t get this working, which is really frustrating. When you search around for this, i’ve found very little. People keep saying “allow access from anywhere” - this is the polar opposite of what i want to do.

Any help greatly appreciated.

I facing the same issues… I cant get it up&running with heroku atlas and
QuotaGuard Static IP’s