Cannot connect to remote mongodb server
The problem was wrong setting of bindIP in mmongod.conf. Changing to:
bindIp: 127.0.0.1,ip_address_of_host_running_mondgod
fixed the problem. Replace ip_address_of_host_running_mondgod
with ip address of host running mongod like 137.142.177.4
Unable to connect to mongo on remote server
The issue was bindIp
didn't change. There was some issue in restarting mongo from my side.
The habit should be to verify if the bindIp actually changed or not. (using sudo netstat -tulpn | grep 27017
)
Failing to connect to remote mongodb server
Firstly, To ensure its not a firewall issue, stop IPTABLES on both servers (don't forget to re-enable afterwards).
On the machine that you are trying to connect to, ssh directly to it and ensure MongoDB is running, Connect locally and check that you can access a DB.
MongoDb isn't configured to accept connections from remote hosts by default, could you ensure you have these lines in your /etc/mongodb.conf
file:
bind_ip = 0.0.0.0
port = 27017
Make sure you restart MongoDB after making any changes. Try this and comment if your still having issues and I'll update the answer with more suggestions.
EDIT: As of version 2.6 the config file format has changed to YAML, details here, the file should be located at /etc/mongod.conf
.
net:
bindIp: 0.0.0.0
port: 27017
Unable to connect to mongodb on remote server
It seems like MongoDB is not accessible over a network there might be several reasons. I have listed some:
- MongoDB port 27017 is not open
- Firewall is blocking the connection with another machine
You can also try adding the authentication information in your URI like this:
spring.data.mongodb.uri=mongodb://user:secret@mongo1.example.com:12345,mongo2.example.com:23456/test
OR
you can split it over multiple properties
spring.data.mongodb.host=mongoserver.example.com
spring.data.mongodb.port=27017
spring.data.mongodb.database=test
spring.data.mongodb.username=user
spring.data.mongodb.password=secret
If you want to check whether there is a problem with the application or MongoDB you can spin up the free Mongo Atlas instance and try to connect that with your application if that works then there will be surely a connectivity issue with our machine
MongoDB, remote connection failing
It was due to network connectivity.
unable to connect remote mongo db server
Finally, i am able to connect to remote mongodb server,
the issue was with the port I was connecting,
I was connecting to a port which was open over UDP but when I make that port changed over TCP I connect very easily(means I talked to my networking team and asked them to make the port 27017 available over TCP).
so moral of the story you can not connect mongodb remote server over UDP port through public ip or through the internet.
connecting to remote mongo server results in exception connect failed
It's a connection problem at your side. I tried it but got a login failure message:
MongoDB shell version: 1.6.5
connecting to: ds045907.mongolab.com:45907/database
Mon Dec 24 01:12:31 uncaught exception: login failed
exception: login failed
MongoDB cannot connect from remote computer
Despite @Sridharan r.g's solution doesn't work, my resolution was inspired by his answer.
I was so close to the solution:
Change the "bindIp" value from "127.0.0.1" in /etc/mongod.conf AND KEEP TWO SPACES BEFORE THE "bindIp", like this:
...
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
...
Please note:
- There must be exactly two spaces before "bindIp": neither too many
nor too few. - In the default file format of MongoDB 3.6, it doesn't use
"bind_ip = " but rather "bindIp:" - There MUST BE AT LEAST ONE SPACE between the colon after "bindIp"
and the IP address (here it is 0.0.0.0) - If you want to add more than one IP addresses, use comma to separate
each values, and KEEP AT LEAST ONE SPACE between the comma and the
next IP address.
The file format is a little bit tricky, check here the file format specification.
Related Topics
Vagrant Synced Folders Not Working Real-Time on Virtualbox
Warning Building a Kernel Module That Uses Exported Symbols
Where to Start Learning About Linux Dma/Device Drivers/Memory Allocation
Multiple Ble Connections Using Linux and Bluez 5.0
How to Use Iptables in Linux to Forward Http and Https Traffic to a Transparent Proxy
Sort by Multiple Columns in Bash
How to Ignore Some Differences in Diff Command
Using Mkdir -M -P and Chown Together Correctly
Curl Does Not Work But Same Site Works with Browser
Run Matlab in Linux Without Graphical Environment
Concatenating Two String Variables in Bash Appending Newline
All Newlines Are Removed When Saving Cat Output into a Variable
How to Query X11 Display Resolution
Why Characters Received in Serial Connection Only After Pressing Enter