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