3

I am working on a MERN project. I was previously able to connect to the MongoDB cluster via the connection string in my node application. A few days ago I changed my wifi router and I am not able to connect to the database anymore.

I am sure the problem is the router because when I connect through my phone's internet, the connection is successful. Unfortunately, I cannot use my phone's internet always as it is really expensive.

I have tried to factory reset my router as suggested in this question.

Error at connecting to MongoDb Atlas Server

I have also tried to enable port forwarding for port 27017, 27018, 27019 (default ports of MongoDB) through the router settings as suggested by someone on the internet.

Screenshot of my router settings

But did not face any success.

Some additional information. I am using a d-link router(DIR-819). The latest version of windows, node.js at the time of asking this question. Any help would be greatly appreciated as I am stuck on this problem for hours now.

EDIT: Here is the output when I try connecting through the shell. DNSHostNotFound: Failed to lookup service ": This operation returned because the timeout period expired. try 'mongo --help' for more information. Please help me out, guys. I have whitelisted all the IP addresses.

Cheers Everyone

  • 1
    Can your browser reach the Atlas UI through the router? If so, check the whitelist, the new router may have a new IP address. – Joe Jul 11 '20 at 10:02
  • I have whitelisted all IP address'. So that is not a problem. As I said the problem is only with my main network. I can connect to the DB through my phone's network and even though my office's network. – Jaskaran Singh Jul 11 '20 at 10:05
  • The `DNSHostNotFound` part suggests the problem is occurring before the port number is relevant. Try using the pre-3.6 connection string with all the hostnames in it. – Joe Jul 11 '20 at 23:01
  • Did you solve this? I am having similar issue. @JaskaranSingh – Shruti Aug 17 '20 at 10:48
  • Did you able to solve this bro..?? @JaskaranSingh – sahil555 Sep 09 '21 at 18:14

3 Answers3

0

Okay, look I'm also facing the same issue. The reason behind this is because your Router is not letting your backend to make a connection with the MongoDB atlas. You can still use it through your mobile network. Connect your PC with your mobile network and then try again it will work. (worked for me)

And for the Router issue, I'm still searching the solution once I find it, I'll be updating the answer. And yes if you find the solution before me be sure to Update us.

0

Use MongoDB in local machine. If that helps. I was also facing a similar issue so dropped the idea of connecting it to MongoDB Atlas. I downloaded it and it's running smoothly

Shruti
  • 109
  • 9
0

Try to downgrade nodejs driver. I have resolved this by downgrading nodejs 3.2 driver string to 2.2 driver string. enter image description here

Shahrukh
  • 47
  • 2
  • 8