Router cannot connect to MongoDB cluster - node.js

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

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.

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

Try to downgrade nodejs driver. I have resolved this by downgrading nodejs 3.2 driver string to 2.2 driver string.

Related

RaspberryPi Webserver /Cant Access Nginx Server via external public ip. What am i missing? Timeout

im trying now for hours and didnt get any further. I just got a simple Express app and an nginx server running on my raspberry pi.
Problem: I cannot access it through the external api. I always got a timeout :/
Steps that i took:
Configured Sites-available.
Checked for listeners:
[
Tried all port-forwarding stuff i could found in the router settings:
(its german but i guess u get the point)
Please help me ! Thx in advance :)
Problem Solved
The missing point was my router. Not every Router supports to access the external API while ure connected with the youre local internet.
I turned of the WI-FI on my phone and were able to access the site via external ip adress and the domain routing to it.
I hotspoted my PC and were also able to access the website
!! Most modern routers allow accessing while you stayed connect locally to the internet, so in most set up guides they didnt mention.
Hope i could help someone in future trouble.
For me it was a waste of 4-5 h. Happy Coding guys!

Alternatives for connecting MongoDB Atlas to Heroku Node.js app

I've been working on a simple website using node.js, express, and MongoDB, with Heroku as the platform. I had a lot of issues early on trying to connect to my MongoDB Atlas cluster, resulting in Heroku throwing request timeout errors.
After some googling, I surmised that the issue was that the IP addresses Heroku sends requests to my DB from weren't whitelisted in Atlas. The simplest solution at that point was to egregiously set up so that any IP is considered whitelisted. Which actually works fine currently.
My actual question comes down to the fact that whitelisting all IPs hardly seems like a professional way to go about doing things.
What is a better solution?
You should only allow those IPs from which your application will connect to MongoDB Atlas. Allow all IPs is a bad practice and could make that MongoDB instance vulnerable.

queryTxt ETIMEOUT merncluster-0jdze.mongodb.net

I'm using nodejs with MongoDB server using mongoose, whenever I try to run my server, it won't connect to my database. After sometime above log is seen on CMD. My cluster name is merncluster here!!
Is there any solution to this, I've searched a lot, still can't find proper solution to this, this keeps happening all the time.
You may need to whitelist your IP address in MongoDB Atlas.
Adding 8.8.8.8 to my connection to the internet works for me.

Does node.js server need internet connection to run?

I disable the internet connection and run the node server npm start, then it throws the error:
And now enabling internet connection and running the server works fine:
So, I want to confirm if this really needs to be connected to the internet while starting the server?
If it really needs internet connection, then is there any idea to run the server offline?
If I connect to the internet and run the server and there after plug out the internet connection then there's nothing goes wrong. Everything works fine. I don't know why just running the server requires the internet connection.
OMG! It's really cool! I got it working offline after hard research in my code using 127.0.0.1 instead of localhost for mongo uri.
Using localhost needed for me to connect to the internet.
And using 127.0.0.1 worked in both condition i.e. with internet connection and without internet connection.
But, really I'm totally amazed of this.
I found the really cool topic on this which made me clear about this.
If you use 127.0.0.1, then (intelligent) software will just turn that directly into an IP address and use it.
And there's no guarantee that your hosts file will actually be used for that resolution (first, or at all) so localhost may become a totally different IP address.

Socket.IO Connection Not working on University Wifi

I have created an chat app using Socket.IO . It works fine on my home internet. But whenever I am at my university and connected to versity wifi internet, I can't get connected at all. Its facing 'net::ERR_CONNECTION_TIMED_OUT' error.
Here is the url: demo.codesamplez.com/ultrachat/demo.html (You will may get it OK, as I do on home)
I guess, this might be some kind of firewall issue or something?
Does anybody has any clue how to go forward for solving this? Thanks in advance.
Switching from HTTP to HTTPS should get around the problem with incompatible proxy server. That forces the proxy to use HTTP tunneling to maintain the connection instead performing whatever magic it does.

Resources