By: Emiley J in NoSQL Tutorials on 2018-12-27
While trying to connect to a newly installed MongoDB server from Mongo DB complass client application, you may see this error. Here is a solution for this issue.
There may be a few reasons that could have caused this issue.
- The mongodb service is not running
- Some network issue
- Some firewall issue
Let us see each of these issue and resolve them one by one.
The mongodb service is not running
First of all make sure that the mongodb service is running. If you are using windows, goto services and then scroll down and check that the mongodb service is running. If you are on a linux machine, type 'service mongod status' and check that the service is active and running.
Some network issue
If you are sure that the mongodb service is running then make sure there is no network issue. Usually the default mongodb service listens on port 27017 and IP: 127.0.0.1. This works great as long as you are connecting from localhost and there are no funny network settings. In some cases you may have to open the config file and make mongodb listen to both 127.0.0.1 as well as your private IP of your machine. If you are using Windows, you can check your private IP using 'ipconfig' command and in linux using 'ifconfig' command. Once you know the IP of your machine, edit your config file and add this ip as follows:
In windows it is usually this path. C:\Program Files\MongoDB\Server\4.0\bin\mongod.cfg and in linux it is /etc/mongod.conf. Edit this line bind_ip: 127.0.0.1 as below
bind_ip: 127.0.0.1, xx.xx.xx.xx
Where xx.xx.xx.xx is your private IP.
Save the file and restart the service.
Some firewall issue
Even after you do steps 1 and 2 above, if you still cannot connect then probably the port 27017 is not open or blocked by firewall. In windows, you may edit the windows firewall and open this port. If you are using AWS or some other cloud hosting, then you may need to configure the 'security group' or equivalent firewall setting and open this port for external access.
After these 3 steps, you should be able to access mongodb from anywhere
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)
- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.
- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Most Viewed Articles (in NoSQL )
Latest Articles (in NoSQL)
- Data Science
- React Native
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews