in /etc/mongodb.conf file I have this setting bindIp: ",", is my private ip given by my router. when I do systemctl status mongodb:

mongodb.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2016-09-26 17:51:40 CST; 32s ago
   Process: 1070 ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf (code=exited, status=48)
   Main PID: 1070 (code=exited, status=48)

when I check /var/log/mongodb/mongod.log this is what I get:

2016-09-26T17:55:05.129-0600 I CONTROL  [main] ***** SERVER RESTARTED *****
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] MongoDB starting : pid=2916 port=27017 dbpath=/var/lib/mongodb 64-bit host=goku
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] db version v3.2.9
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] git version: 22ec9e93b40c85fc7cae7d56e7d6a02fd811088c
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2i  22 Sep 2016
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] allocator: tcmalloc
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] modules: none
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] build environment:
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten]     distarch: x86_64
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten]     target_arch: x86_64
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] options: { config: "/etc/mongodb.conf", net: { bindIp: ",", port: 27017 }, processManagement: { pidFilePath: "/var/run/mongodb/mongod.pid" }, security: { authorization
: "enabled" }, storage: { dbPath: "/var/lib/mongodb", engine: "wiredTiger", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
2016-09-26T17:55:05.163-0600 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=6G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),f
2016-09-26T17:55:05.521-0600 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongodb/diagnostic.data'
2016-09-26T17:55:05.521-0600 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-09-26T17:55:05.522-0600 I NETWORK  [initandlisten] waiting for connections on port 27017

however I can run systemctl restart mongodb and everything works

I have edited /usr/lib/systemd/system/mongodb.service and added these two lines:

Requires=NetworkManager-dispatcher.service NetworkManager.service
After=syslog.target NetworkManager-dispatcher.service NetworkManager.service

so the one million dollars question is, what else should/could I do to make it work on start up time?

thanks for your help :-)


Your logs say that the process started successfully (that last line indicated success), but your service status is saying it has exited.

The logs are far more likely to be correct, the service has started successfully but the process IDs (PID) don't seem to match. Your service status is looking at PID 1070 and the log shows 2916. I suspect that is your issue, and my main suspect as a cause would be the pidFilePath option. Check out what is actually in that file and try removing that option, see if that fixes the issue.

  • Thanks for your reply! when starting my system the pid file, doesn't exists, and mongodb is in a failed state. But then I'm able to start the process systemctl start mongodb without a problem. I also removed the option of the pidfilepath and I get the same behaviour
    – juanp_1982
    Oct 23 '16 at 22:27
  • You seem to be missing the failed state logs from your question though - the logs you posted don't show a failed start, they show a success. Can you post the ones with the failure? Oh, and your OS/Version would be helpful too.
    – Adam C
    Oct 24 '16 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.