Unifi Upgrade – MongoDB does not start

Recently had an issue where upgrading Unifi resulted in MongoDB not starting. Looking to the /var/log/unifi/mongod.log we see:

ERROR: Insufficient free space for journal files
[initandlisten] Please make at least 3379MB available in /usr/lib/unifi/data/db/journal or use --smallfiles
[initandlisten]
[initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
[initandlisten] dbexit:
[initandlisten] shutdown: going to close listening sockets...
[initandlisten] shutdown: going to flush diaglog...
[initandlisten] shutdown: going to close sockets...
[initandlisten] shutdown: waiting for fs preallocator...
[initandlisten] shutdown: lock for final commit...
[initandlisten] shutdown: final commit...
[initandlisten] shutdown: closing all files...
[initandlisten] closeAllFiles() finished
[initandlisten] journalCleanup...
[initandlisten] removeJournalFiles
[initandlisten] shutdown: removing fs lock...
[initandlisten] dbexit: really exiting now

This is caused by the disk space being too low (under 3.3GB). Taking a look at the filesystem, we can see this is the case:

The type service unifi restart and you should be good to go.

One issue I found from this is that the MongoDB is increasing at a rapid rate. I found an excellent script here which prunes the content in MongoDB for Unifi Controllers.

Unifi 5.6.22 Upgrade Fails to Start Linux ERROR system – [exec] error, rc=255

When upgrading Unifi to 5.6.22, you will find that Unifi does not start on Linux system.

If you see the log files, you will see something like this:

/var/log/unifi/system.log

 <UniFi> ERROR system - [exec] error, rc=255

This is because of a change in the release notes:

The controller will not start if it is set to bind to a privileged port (<1024), as it now runs as a non-root user

To fix this, you must change your config file to use a port outside of the 1024 range. This will be an issue if you’ve changed your port, like me.

  1. Edit /var/lib/unifi/system.properties
  2. Change your ports from
    unifi.http.port=80
    unifi.https.port=443

    to

    unifi.http.port=8080
    unifi.https.port=8443
  3. Now type
    sudo service unifi restart

You should now be able to login to your system using the new ports.