Restrict MongoDB access to Netlify web app

Hi there!

I have connected a web app hosted on Netlify with a MongoDB Atlas database.

In that database I can restrict access to specific IP adresses. Apart from my local IP address, I only want the netlify servers from by web app access the database. (Currently, I have added 0.0.0.0/0 which grants access to anyone with the credentials.) For this, I need to find out their IP adresses. I have followed the instructions at Finding the IP addresses for Netlify’s nameservers. But when I did that, the database connection was not possible anymore.

Specifically, the domain servers are:

And their IP adresses are:

  • 198.51.44.1
  • 198.51.45.1
  • 198.51.44.65
  • 198.51.45.65

I have added them to the MongoDB network access:

(I have crossed out my own IP address)

When I removed 0.0.0.0/0, access stopped working.

Maybe the domain servers are not actually the correct servers here?

Adding in the nameservers won’t help as content isn’t served from those addresses. Content is served from the CDN IPs which are numerous and always changing.

A quick search through the forums on this topic would have provided you the following simple answer

There are other methods described through the forums should you care to read.