I just want to try MongoDB Compass GUI for MongoDB, but when I try to connect using local host port: 27017 I get this error:
Could not connect to MongoDB on the provided host and port
I followed these instructions on YouTube.
I just want to try MongoDB Compass GUI for MongoDB, but when I try to connect using local host port: 27017 I get this error:
Could not connect to MongoDB on the provided host and port
I followed these instructions on YouTube.
I had faced this issue today and later I found that it was a set up problem. If you are also facing this issue while you set up MongoDB for the first time, following steps may help you. Make sure that MongoDB
service has been started in services.msc
.
db
in the path C:\data\db
, if you don't see data
folder in C drive, please create it first and then db
folder as @sebastian mentioned in the comment. C:\Program Files\MongoDB\Server\3.6\bin
C:\Program Files\MongoDB\Server\3.6\bin>mongod
C:\Program Files\MongoDB\Server\3.6\bin>mongod 2018-03-11T07:02:56.558-0700 I CONTROL [initandlisten] MongoDB starting : pid=18720 port=27017 dbpath=C:\data\db\ 64-bit host=SibeeshVenu 2018-03-11T07:02:56.558-0700 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
db
folder in the path other than C:\data\db
? –
Antons Press windows key button and search Services and find MongoDB then start. Then try again. It will work
In case other people have this error, here is what worked for me:
Under network comment out the following by placing a # at the beginning of the line:
bindIp: 127.0.0.1
-- What went wrong: --
Reason: bindIp was causing it to reject external requests, so we need to remove that setting.
My mongo was the standard yum install for Red Hat (RHEL6) and this is how it was configured by default (I had started with mongoDB 2.6 and upgraded in steps to 3.4).
EDIT: For MongoDB 2.4 and earlier use: bind_ip = 127.0.0.1
Struggled for 3 hours.
Here is full procedure in 3 steps:
Get the IP adresss:
CMD
or Command prompt ipconfig
command10.111.11.111
Edit the bindIP in MongoDB Server config file:
C:\Program Files\MongoDB\Server\4.0\bin\mongod.cfg
bindIp: 127.0.0.1
bindIp: 127.0.0.1,10.111.11.111
NOTE: If your IP address changes everyday, then best is to write the computer name (type hostname
in cmd
to get the name of your computer)
Restart the MongoDB Server
services.msc
commandMongoDB Server
Restart the service
Connect to MongoDb server, from another machine
Now, you can connect from another machine.
Use a client, like MongoDB Compass
or other:
10.111.11.111
, give it in Hostname
in MongoDB Compass client Hostname
in MongoDB Compass client can also be the server's computer name like W11ABC11A11. To get computer name of your MongoDB server, use hostname
in CMD
(on the MongoDB server computer).After doing all above, if you have issues, then:
- ping each other (client from server, and vice versa) using ipconfig
, using command ping IPhere
, you should get Reply from ..
should not get Request timed out.
- if you see issues in above:
-- Restart the client machine, ping again
-- If you still have issues, have DB owner to restart the server machine once (if it is dev server there should not be any problem to restart when its idle.)
-- issues still? verify all above steps
Hope that helps.
I had the same problem
edit /etc/mongod.conf
Under the net settings
bindIp: 0.0.0.0
It's a common problem if you are working on Windows.
Open your task manager and go to the Services tab. Check if the MongoDB server is stopped or not. If stopped, right click on it and start the server. Then try again. The problem will be solved.
Wasted a lot of time on this, seemingly tried it all and literally none of these solutions worked for me...
Ultimately, my MongoDb seems to want to ignore my config file, since commenting out the bind_ip field should do the same thing.
Try starting mongo like this
mongod --bind_ip_all
Alternatively, you can specify specific IPs
mongod --bind_ip <IP>
My MongoDB Installed machine firewall was enabled that's why I can not from Remote machine MongoDB compass
After disabled the firewall, I am able to connect from Remote MongoDB compass.
[17:32:51 oracle@test2 bin]$ service firewalld stop
Thanks
Check if 27017 port is enabled / Opened in your .conf file .. This is because 27017 port is not opened as default and also you need to add your IP in the TCP IN to make your internet IP connect remotely..
It's a common problem if you are working on Windows.
Creating data/db
folder on c
drive and then running mongod from C:\Program Files\MongoDB\Server\4.2\bin
and then connecting from mongodb compass resolves my issue
basicly on c drive you should have data
folder which holds db
folder that's what i understood by this
i just shared someone might get help from this :)
I am on Ubuntu and I simply did it by checking the 'mongod.conf' file. Make sure that following parameters are set:
net: port: 27017 bindIp: 127.0.0.1
And after every change I suggest you go with
sudo systemctl restart mongod.service
By default IPv6 disabled and this may be a reason of the failed connection by Hostname. Try to add IPv6 support:
# network interfaces
net:
ipv6: true
port: 27017
bindIp: 127.0.0.1, MyDomain.com
© 2022 - 2024 — McMap. All rights reserved.