Starting with Ubuntu 15.04, Upstart was replaced by systemd. MongoDB installed cleanly, but the service did not start automatically because the packaged unit files were out of sync with the new init system.

Historical context

This is a legacy Ubuntu 15.04 note, not current MongoDB installation guidance. The value is in the failure pattern: packages that still assume Upstart can install successfully but fail to register a working systemd service.

For modern Ubuntu releases, use MongoDB's current repository instructions and systemd unit files. For older hosts that cannot be upgraded immediately, the steps below show how to diagnose and recover the service registration.

The first clue appears during installation (official install steps):

invoke-rc.d: mongod.service doesn't exist but the upstart job does. Nothing to start or stop until a systemd or init job is present.

service mongod status confirms the service is not running:

● mongod.service
Loaded: not-found (Reason: No such file or directory)
Active: failed (Result: exit-code) since Tue 2016-01-12 17:37:43 GMT; 6min ago
.....

There is also no usable init.d file for mongod.

What did not work

I tried restoring the legacy init.d script from the MongoDB repository, but the service still failed to start under systemd.

cd /etc/init.d

wget https://raw.githubusercontent.com/mongodb/mongo/master/debian/init.d -O mongod

chmod +x mongod

./mongod start

resulting in

[....] Starting mongod (via systemctl): mongod.serviceFailed to start mongod.service: Unit mongod.service failed to load: No such file or directory.
failed!

Working approach: create a systemd unit

Create an explicit systemd service file for mongod:

[Unit]
Description=MongoDB Database Server
After=network.target
Documentation=https://docs.mongodb.org/manual

[Service]
Type=simple
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --config /etc/mongod.conf
LimitNOFILE=64000
TimeoutStopSec=30
Restart=on-failure

[Install]
WantedBy=multi-user.target

This unit assumes mongod stays in the foreground, which is the normal systemd model. If your installed /etc/mongod.conf enables forking or uses a different user, data directory, or binary path, adjust the unit to match the package you actually installed.

Save it as:

sudo vi /etc/systemd/system/mongod.service

Then reload systemd and start MongoDB:

sudo systemctl daemon-reload
sudo systemctl enable mongod
sudo systemctl start mongod

Verify the service

Check systemd status:

sudo systemctl status mongod

Confirm the process is listening locally:

sudo ss -lntp | grep 27017

Confirm MongoDB accepts a local connection:

mongo --eval 'db.runCommand({ connectionStatus: 1 })'

On newer MongoDB releases the shell command may be mongosh instead of mongo.

Operational caveats

Ubuntu 15.04 is end-of-life, so this should only be used for recovery on legacy systems. If the server is internet-facing or stores important data, plan a migration to a supported Ubuntu and MongoDB version instead of treating this as a permanent fix.

Before changing service files on an existing database server, take a filesystem or volume snapshot and confirm the MongoDB data directory path in /etc/mongod.conf.