How to Connect with MongoDB Server
MongoDB looks for a database server listening on port 27017 on the localhost interface.
Note: For connect to a server on a different port or interface, use the –port and –host options.
1. Run this : D:\mongodb\bin\mongo.exe
D:\mongodb\bin>mongo.exe
MongoDB shell version: 2.6.4
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
>
>
2. Establish connection from other machine.
D:\mongodb\bin>mongo --host localhost --port 27017
MongoDB shell version: 2.6.4
connecting to: localhost:27017/test
> exit
bye
3. Tried to connect with different port, it failed due to different port number specified.
D:\mongodb\bin> mongo --host localhost --port 27015
MongoDB shell version: 2.6.4
connecting to: localhost:27015/test
2014-09-09T11:25:48.682+0530 warning: Failed to connect to 127.0.0.1:27015, reas
on: errno:10061 No connection could be made because the target machine actively
refused it.
2014-09-09T11:25:48.682+0530 Error: couldn't connect to server localhost:27015 (
127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:148
exception: connect failed