neiljny
By:
neiljny

How do I restart mongodb?

April 5, 2015 25.3k views
MongoDB One-Click Install Apps

I installed mongoldb using the one-click installer. I changed the config bind-ip and commented it out (to allow it to accept any connection). Then I wanted to restart to make the changes take effect, so I did the following:

root@mongo:~# mongo
MongoDB shell version: 3.0.0
connecting to: test
> use admin
switched to db admin
> db.shutdownServer();

Then I expected it to try and reconnect, however this happened:

2015-04-05T11:36:13.492-0400 I NETWORK  DBClientCursor::init call() failed
server should be down...
2015-04-05T11:36:13.495-0400 I NETWORK  trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2015-04-05T11:36:13.496-0400 W NETWORK  Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-04-05T11:36:13.496-0400 I NETWORK  reconnect 127.0.0.1:27017 (127.0.0.1) failed failed couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed

How can I restart my mongod process?

1 comment
  • Hello Guys, I installed mongodb in my ubuntu 15.10. When I run mongo comment gotting below error

    $ mongo
    MongoDB shell version: 2.6.10
    connecting to: test
    2016-07-02T11:12:17.792+0530 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
    2016-07-02T11:12:17.794+0530 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
    exception: connect failed

    Please provide solution. When I run rockmongo I got the below error

    Unable to connect MongoDB, please check your configurations. MongoDB said:Failed to connect to: 127.0.0.1:27017: Previous connection attempts failed, server blacklisted.

    Unable to connect MongoDB, please check your configurations. MongoDB said:Failed to connect to: 127.0.0.1:27017: Connection refused.

    Please answer me as soon as possible.

1 Answer

You can start MongoDB by running the following command as root:

sudo service mongod start
  • Thanks, this worked perfectly :)

    • HI @neiljny, after changing the config bind-ip and commented it out, I could connect to the server ip with port 27017 but the authorization failed using the username (root) and server password (which I use to SSH connect via terminal). I don't know where I'm wrong. I use Robomongo btw

Have another answer? Share your knowledge.