skip to Main Content

I created a database and server for a front end application that I built, and I’m now trying to deploy the server to heroku. I’ve set up my config vars, I created the cluster in Atlas, and the server works locally.

When I deploy to heroku I receive this error
MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/

I read the provided documentation and checked to make sure my IP address was listed and it is. Here is a link to all of my server code, but I have a feeling it is more of an Atlas/Heroku error and I don’t know where to even begin.

https://github.com/maxd66/valorant-random-server

2

Answers


  1. You can install Heroku add-on that provides static IP address, for instance this one, and whitelist that static IP in Atlas.

    Please find more info in this MongoDB blog post

    Login or Signup to reply.
  2. You can set different IP addresses to access your MongoDB cluster. By using the following path: SECURITY > Network Access and add your ip address.
    You can find your ip address from https://whatismyipaddress.com/tr/ip-im .

    If you want to access from all IP addresses, just add 0.0.0.0 to your network table.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search