Obviously, you can connect to MongoDB on the "localhost" port 27017. You should be able to open the MongoDB shell without arguments and get a hint back:
Β» mongo MongoDB shell version: 1.8.1 connecting to: test >
If you cannot answer, this should be obvious: MongoDB is not working. You want you to start the MongoDB server process. There are several Quickstart Guides in MongoDB Docs that should help you choose a process on your platform.
Otherwise, you will not indicate which platform you are running on, but there is a problem with how Java resolves certain host names, such as "localhost" on Mac OS X ... This is actually a Java problem, not a Java problem MongoDB drivers,
When asked to allow "localhost" with the host name on InetSocketAddr , Java for Mac will usually return the IP address of your external interface. Since several installers for Mac MongoDB, such as Homebrew, block the listening IP address to 127.0.0.1, this may cause the connection to "localhost" to complete completely with the Mac with Java.
Brendan W. McAdams
source share