I'm having trouble remotely connecting to my MongoDB instance; I've deployed it using the MongoDB AWS Quick Start, and can connect via SSH as per the "Testing" section of the Quick Start guide.
However, when trying to connect remotely (I'm using the PyMongo driver), I run into a pymongo.errors.ServerSelectionTimeoutError: ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com:27017: timed out error.
I've tried setting bind_ip to 0.0.0.0 as well as an Elastic IP to the VPC instance that the mongod is running on, but to no avail. In fact, even pinging the EIP leads to a timeout (although pinging the NAT instance doesn't).
With PyMongo I've tried both DNS's, with and without SSL. I can successfully connect to MongoDB on localhost.
These are the security groups for the VPC: AWS security groups
If anyone has a clue on what I might be doing wrong I would greatly appreciate it; I've been struggling with this for over a day now. Thanks!
Related
i think this question been asked many times, but i've had this issue also last year and another last year, i resolved it to use VPN provider like nordvpn and tunnelBear. my issue here my company has own VPN which to connect to some internal apps, but i cant connect with multi VPN, my company VPN not resolved the issue to connect Mongo Atlas into Compass, after i install NordVPN in my Linux Fedora, it was solve, but i can't open another internal app if i dont connect with my company VPN. so i tried connect my company VPN while my NordVPN connected as well, but it doesnt work. i need to turn off my private VPN to connect my company VPN. this is really confusing for me if keep to turn off and on my private VPN and Company VPN for my work.
wha i have tried to fix this issues but always failed
change DNS on my fedora /etc/resolv.conf into nameserver 0.0.0.0 or nameserver 8.8.8.8;
change net.bindIp on /etc/mongod.conf into 0.0.0.0 and my ip;
listed ip public in Mongo Atlas 0.0.0.0;
error on mongo compass after paste the URI:
querySrv ENODATA _mongodb._tcp.companyNameHere.ycex0.mongodb.net
error in mongo shell
MongoDB shell version v4.4.3
exception: Failed to look up service "_mongodb._tcp.companyNameHere.ycex0.mongodb.net": Success
exiting with code 1
error in Go app:
panic: error parsing uri: lookup _mongodb._tcp.companyNameHere.ycex0.mongodb.net on XXX.XXX.1.1:53: no such host
those ways not work in my Fedora, i cant connect Mongo Atlas URI in Compass, Go App and Shell as well,
is that any another way ?
my os is: Fedora 33
Try using the standard connection string , as SRV strings sometimes not resolvable by some of the images.
The standard connection string can be obtained in the Atlas UI for the version 3.4 earlier
I have installed and running mongodb on port 27017 of my VM on gcp. But I am not able to access database from my pc or any external client.
I have set firewall rules to allow ingress traffic with tcp protocol on port 27017(tcp:27017) from all ip ranges(0.0.0.0/0) and have set priority 1000.
firewall rules snapshot
Now when i am trying to access the database from external client I am not able to access it. I even tried mongodb compass and used ip address of VM and port 27017 to access the database. But unable to connect and showing(mongodb not running on provided host and port) however I am able to access to database when accessed from that VM itself in which I have installed the mongodb.
Please suggest if I am missing out anything.
By default, MongoDB doesn’t allow remote connections. So I would suggest you follow this tutorial to resolve your issue.
Let me know if this was helpful.
Add --bind_ip_all to mongodb server start command.
My server is running on AWS EC2 and I noticed that it has 45000 mongo connections from our app's server IP. Though in code, there is only one mongo connection getting created at start.
Can anyone help me out here in debugging why it has so many connections?
PS: We use PM2 to restart the server, could it be because of that?
I'm trying to connect my app running on AWS EC2 to mlab endpoint. I can easily connect using the same code base from my local machine to mlab endpoint. However, when I run on AWS, I get the following error.
{ name: 'MongoError', message: 'connect ECONNREFUSED' }
I have tried increasing connectionTimeMS to 30 seconds, but I still get the same error.
From EC2 instance, I can ping the DB server and netcat is also successful.
My EC2 instance is configured to receive and send all traffic on all ports from any IP address.
I think issue might be related to outgoing traffic, but do not know how to configure.
Thanks
Turned out to be environment issue.
I was setting my mlab endpoint using the command
export MONGOLAB_URL='xxxx'
and then running my app
sudo node server.js
this sequence does not set my local environment.
All I had to do in the end was to use the following command
sudo MONGOLAB_URI='xxxxxx' node server.js
I'm new to MongoDB. I'm trying to connect to my remote mongo database from my work machine( I tried for both mongohq as well as mongolab). I'm getting the error listed below. When I run the same command from my home machine it runs fine and does connect to remove mongo database. I'm not sure what is messed up on my work machine but I'd like to fix it. Thanks for you help.
MongoDB shell version: 2.4.9
connecting to: linus.mongohq.com:10097/mydb
Thu Jan 16 04:16:02.689 Error: couldn't connect to server linus.mongohq.com:10097
at src/mongo/shell/mongo.js:147
exception: connect failed
As per question comments, your mongo shell client can't connect to the mongo instance. Assuming that your internet connectivity is fine, the most common reason for the failure is that the ports are blocked on your network.
Some ISPs automatically block these ports by default as an additional security protection for users that don't need them open. Contact your ISP or network admin, they should be able to help you out.