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.
Let us see each of these issue and resolve them one by one.
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.
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\Server4円.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.
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:
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:
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)
© 2023 Java-samples.com
Tutorial Archive: Data Science React Native Android AJAX ASP.net C C++ C# Cocoa Cloud Computing EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Trends WebServices XML Office 365 Hibernate
Latest Tutorials on: Data Science React Native Android AJAX ASP.net C Cocoa C++ C# EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Cloud Computing WebServices XML Office 365 Hibernate