Ubiquiti UniFi Controller Failed to Start on Raspberry Pi

tl;dr

  • Installing the UniFi Controller on Raspbian on a Pi failed to start
  • Fixed by installing Java 8 first then re-installing instead of letting apt auto select Java 9
sudo apt remove unifi
sudo apt-get autoremove -y
sudo apt install openjdk-8-jre-headless
sudo apt install unifi
sudo service unifi start
sudo service unifi status

Background

I’m running Raspbian 4.19, so I followed the official UniFi “How to Install and Update via APT on Debian or Ubuntu”.

sudo apt update && sudo apt install ca-certificates apt-transport-https
echo 'deb http://www.ui.com/downloads/unifi/debian stable ubiquiti' | sudo tee /etc/apt/sources.list.d/100-ubnt-unifi.list
sudo wget -O /etc/apt/trusted.gpg.d/unifi-repo.gpg https://dl.ui.com/unifi/unifi-repo.gpg
sudo apt update
sudo apt install unifi

Once installation of all the dependencies and unifi was complete I went to https://my-pi:8443/ in my browser on my PC but I saw a connection refused.

UniFi Controller not Starting

Ok, I thought it might be the firewall, so I did:

sudo ufw add 8443

but still no connection.

On the Pi I tried wget https://localhost:8443, but also got connection refused.

I checked the log files:

/usr/lib/unifi/logs/server.log
/usr/lib/unifi/logs/mongod.log

However, neither file had even been created!

I tried sudo service unifi status but it seemed to show a process that had only just started, usually less than 1 second ago. It looked like it was continually restarting.

After some more searching, help came from the UniFi - Controller FAQ page.

I typed java -version and saw it had installed Java 9, the FAQ says only Java 8 is supported.

Install Java 8 and then the UniFi Controller

sudo apt remove unifi
sudo apt-get autoremove -y
sudo apt install openjdk-8-jre-headless
sudo apt install unifi
sudo service unifi start
sudo service unifi status

Now java -version shows 8 not 9 and the UniFi Controller software starts and runs as intended!