How to Fix “Excess Arguments” Error When Running systemd daemon-reload During MongoDB Setup


13 views

When configuring MongoDB authentication on Ubuntu, many developers encounter the following error when trying to reload systemd:

$ systemd daemon-reload
Excess arguments.

The error occurs because systemd is being called incorrectly. The systemd command doesn't accept daemon-reload as a direct argument - this is a common misunderstanding in the MongoDB setup documentation.

The correct way to reload systemd is using systemctl instead of systemd:

$ sudo systemctl daemon-reload

Here's the proper sequence for enabling MongoDB authentication:

# Edit mongod.conf
$ sudo nano /etc/mongod.conf

# Add security section
security:
  authorization: enabled

# Then reload and restart
$ sudo systemctl daemon-reload
$ sudo systemctl restart mongod

If you still face issues:

# Check systemd logs
$ journalctl -xe

# Verify MongoDB status
$ sudo systemctl status mongod

# Test authentication
$ mongo -u admin -p --authenticationDatabase admin

For those using different init systems:

# For older sysvinit systems
$ sudo service mongod restart

# For direct management
$ sudo mongod --auth --config /etc/mongod.conf

While configuring MongoDB authentication on Ubuntu, many users encounter the following error when trying to reload systemd:

$ systemd daemon-reload
Excess arguments.

This typically occurs during Step 4 of MongoDB authentication setup where you need to reload the systemd configuration.

The error occurs because systemd is being called incorrectly. The proper command should use systemctl instead of systemd. This is a common mistake when following outdated tutorials or misremembering the command syntax.

For systemd operations, you should always use systemctl. Here's the correct way to reload the daemon:

$ sudo systemctl daemon-reload

Note these key differences:

  • Uses systemctl instead of systemd
  • Requires sudo privileges
  • No "Excess arguments" error

For context, here's how the complete authentication setup should look:

# Edit mongod.conf
$ sudo nano /etc/mongod.conf

# Add these lines under security:
security:
  authorization: enabled

# Then restart MongoDB with:
$ sudo systemctl restart mongod

# And reload systemd PROPERLY with:
$ sudo systemctl daemon-reload

If you're still having problems after fixing the systemd command, check:

  • MongoDB service status: sudo systemctl status mongod
  • Journal logs: sudo journalctl -u mongod
  • Configuration file syntax: sudo mongod --config /etc/mongod.conf --fork

While this solution works for Ubuntu, note these variations:

  • On RHEL/CentOS, the config file might be at /etc/mongodb.conf
  • Some older systems might use service commands instead of systemctl
  • Debian might store logs at /var/log/mongodb/mongod.log