I\'ve just installed MongoDB (standard Ubuntu build, not the latest stable) and for some reason I can\'t connect:
Mon Feb 6 03:11:22 Error: couldn\'t connect to
By default, running the mongo
console command will look for mongodb on your localhost, hence the 127.0.0.1
IP which is your local loopback. Also, the default config for mongod
should be available on localhost. Its better to do it this way for now to start, unless you have turned on auth. Make sure you have auth enabled or your database is running openly on your public ip.
When you want to connect to a host other than localhost or your default config, you do:
mongo <host>
Another way is to add mongod option param bind_ip
mongod -–help
--bind_ip arg comma separated list of ip addresses to listen on - localhost by default
--bind_ip_all bind to all ip addresses
mongod --fork --logpath /var/log/mongodb.log --dbpath /data/db --bind_ip 0.0.0.0
I had the same issue just because the silly mistake.
first remove mongodb file which is fine
rm -rf /tmp/mongodb-27017.sock
where I did mistake inside the /etc/mongod.conf
# network interfaces
net:
port: 27017
#bindIp: 127.0.0.1
bindIp: privateIp
instead of
net:
port: 27017
bindIp: 10.1.2.4
for listen to all available ips
bindIp: [127.0.0.1,10.128.0.2]
restart the mongodb
sudo service mongod start
hopefully this answer help for someone
following steps may help you :
5 lastly just invoke command "mongo"
You must specify the IP (199.21.114.XX), by running mongo 199.21.114.XX
.
Otherwise, if you want it to listen on localhost as well, you should remove the bind_ip
setting in your config file.
Update Check your firewall config. Since you're connecting to the external IP, it can be configured to block, even from the local box.
If you are using windows, run the services then check mongoDB server is running, if not running, Start it.
mongoDB server by default run on localhost:27017. Click localhost:27017 the create an admin user first.