Install Unifi Controller On Raspberry Pi in 5 min

I have some smart products at home and one of the things I wanted to do is read out the connected WiFi devices. To do this I need to Unifi Controller to be running 24/7, so I needed a device to run the Unifi Controller on, something small, cheap and with low running costs. That’s where the Raspberry Pi comes in. In this article, I will help you installing the Unifi Controller on the Raspberry Pi step-by-step in 5 minutes.

If have updated this article in March 2019. The default Java version that is installed on the Raspberry isn’t supported anymore by the Unifi Controller (^ 5.10.x). So we are going to replace it with OpenJDK.

We will also add haveged to the installation. This will fix the slow start-up issue of the Unifi Controller on the Raspberry Pi.

What do we need for the Unifi Controller and Raspberry Pi?

Before we can start with installing the Unifi Controller on the Raspberry Pi we need to get some parts and download some software. Of course, we need to buy a Raspberry Pi. You can use a model 2, but if you have to buy one new I recommend to get a Model 3B.

Also you are going to need a MicroSD card, buy atleast a class 10 card. These are the fastest at the moment with 10mb/sec.

Download the following software so to get started:

Step 1 – Getting the Raspberry Pi up and running

First, we are going to start with installing Raspbian on de MicroSD card. Place the MicroSD card in your computer and open Rufus.

  1. First, make sure you select your MicroSD card (check the size and drive letter!)
  2. Click on Select and select the download Raspbian Stretch Lite zip file
  3. Click on Start
  4. You will get a warning that all data will be removed, click Ok and get a coffee πŸ˜‰
  5. Wait until the process is finished

Activate SSH

We don’t want to connect a keyboard and monitor to our Raspberry Pi everything we need to update or change something. So the first thing we do is enable SSH so we can connect remotely to the PI.

Now the following steps should work also on a Windows machine, but I had multiple times that I was unable to open de SD card in Windows Explorer. Don’t waist your time trying if you have the same, just follow the Alternative way to enable SSH below.

So you should be able to do the following to enable SSH:

  1. Open your explorer and open de MicroSD card. (it’s called boot).
  2. Add a new text file and name it SSH
  3. Make sure you remove .txt from the file name. So you are left with a file just named SSH.

If you have trouble opening the SDCard in Windows you can try to use another computer or skip this part. You will then need to connect a monitor (or TV) and keyboard to the Pi and follow the step under Alternative way to enable SSH

Plug the MicroSD card in the Rasberry Pi and connect the power and ethernet cable. The PI will now start up.

Alternative way to enable SSH

Make sure you have a keyboard and monitor / tv connected. Login to the Pi with the following login:

Username: pi
Password: raspberry

Type the following command to open the settings page:

sudo raspi-config
  • Select 5. Interfacing Options
  • Scroll down to P2SSH and press enter to enable it
  • When down press ESC to exit the settings page.

You have now enabled SSH and can continue the follow this guide.

Step 2 – Connecting with SSH

To connect to the raspberry pi we will need to know it’s IP Address. You could make a reservation in your router for it based on the mac adres, but lets asume you didn’t.

Find the Ip Address

We need to find the IP Address of the PI. Open Advanced IP Scanner and click on scan.

Advanced Ip Scanner to find raspberry pi

In the results you will see the Raspberry Pi, note the IP Address, in my case it’s 192.168.1.210.

Connecting to the PI with Putty

Open Putty that you downloaded earlier. Enter the IP Address that we found in the Advanced Ip Scanner and click on Open

Connecting to the raspberry pi with putty

You will get a warning if we trust the host. We do so click yes

SSH security warning

You will need to login, the default credentials are:

Username: pi
Password: raspberry

ssh to unifi controller raspberry pi

Step 3 – Setting up the Raspberry Pi

Before we are going to install the Unifi Controller on the Raspberry Pi we first going to setup the Raspberry Pi self. You can copy paste the command in Putty. Just copy from this article and right click in Putty.

Set a static IP Address

By default, the Pi is using DHCP to get an Ip address. This means that a reboot can cause it to get a new Ip address, which will make it hard to manage it with SSH or to open the Unifi Controller.

So we are going to set a static Ip Address on the network interface:

  1. First, let’s check the current network details. Type: ifconfig
    In the result you will see eth0 and in that block inet: 192.168.x.x. This is the current ip address.
  2. To edit the network config file type the following cmd:
sudo nano /etc/dhcpcd.conf

3. Enable to following lines by remove the # from it and set ip address to a fixed value

#Static IP configuration:
interface eth0
static ip_address=192.168.1.210/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 1.1.1.1 fd51:42f8:caae:d92e::1

In this case, we set the IP address to 192.168.1.210 and the address of the internet router is 192.168.1.1. You also need to set the domain_name_servers, by default entering the router’s address is enough.

Which ip address should you pick? If you don’t know your network layout, keep the first 3 parts of the address the same and choose a value between the 200 and 240 at the end.

When done save and close the file by pressing ctrl + x and choose Y to save it.

Now we need to restart the network interface to apply the settings. Simply reboot the Pi with the cmd below. Wait a minute and connect to the PI with Putty on the new IP Address.

sudo reboot

Change the default Password

Just with every (network)device you have, you should change the default password. To change the password you will need to enter the current password first and then enter the new password twice:

Enter the cmd passwd:

[email protected]:~ $ passwd
Changing password for pi.
(current) UNIX password:raspberry
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Updating your Raspberry

Before we start installing software on the PI, we will make sure the Raspberry Pi is up-to-date. With the cmd below we will update the firmware, software and clean up unused and old software.

sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get autoremove && sudo apt-get autoclean

This may take a minute or two. When done you will need to reboot the Pi. Sudo Reboot and reconnect your Putty a minute later.

Install haveged

Not really necessary, but the startup of the Unifi Controller can take a bit long on a Raspberry Pi due to the fact there is no user interaction. Now you Pi should be running 24/7, so it’s not a big deal, but we can speed it up anyway.

Install haveged to solve the issue with the following cmd:

sudo apt-get install haveged -y

Update Java 8

This step is pretty important with the newer release of the Unifi Controller. Starting with version 5.10.x the old Java version that comes with Raspbian isn’t supported anymore. So we are going to replace it with OpenJDK 8.

sudo apt-get install openjdk-8-jre-headless -y

Split memory

If you run the Raspberry Pi without a monitor connected you can safely reduce the amount of ram used by the GPU. By default, the Pi has assigned 64MB RAM to the GPU. Because we are using CLI (Command Line Interface) to work on the Pi, we can reduce that amount for RAM, leaving more RAM available for the Pi self.

Open the Raspberry Pi config with the following command:

sudo raspi-config
  1. Select 7. Advanced Options
  2. A3 Memory Split
  3. Change 64 to 16MB
  4. Hit Enter and use Esc to close the config screen.

Make sure you reboot the Pi to apply the changes.

Step 4 – Installing the Unifi Controller Raspberry Pi

So with our Raspberry Pi ready we can start with installing the Unifi Controller on the Raspberry Pi.

1. Add the repository for the Unifi Controller

All Linux distros come with a source list, repository, of available packages to install. Unifi Controller is not listed in the default repositories, so we need to add it first:

echo 'deb http://www.ui.com/downloads/unifi/debian stable ubiquiti' | sudo tee /etc/apt/sources.list.d/100-ubnt-unifi.list

2. Authenticate the software

To install the Unifi Controller software we need to authenticate the software that it’s the real software from Ubiquiti. This can be done with a gpg key so we can authenticate the software.

sudo wget -O /etc/apt/trusted.gpg.d/unifi-repo.gpg https://dl.ubnt.com/unifi/unifi-repo.gpg

3. Install the Unifi Controller

We now have added the software to our list of available software and have the ability to check its authenticity. So let’s download the software and install the Unifi Controller on the Raspberry Pi:

sudo apt-get update; sudo apt-get install unifi -y

4. Cleanup MongoDB

The installation may take a couple of minutes to complete. When done, we need to remove the default database that comes with MongoDB instance. This would only waste resources of our Pi, so we get rid of it:

sudo systemctl stop mongodb 
sudo systemctl disable mongodb

5. Finished

The only step left is to reboot the Pi

sudo reboot
Unifi Controller Raspberry Pi

Wrapping up

After the reboot, you can log in to the Raspberry Pi with your browser. Goto the Ip address you set earlier: https://192.168.1.210:8443

The setup wizard page will be displayed allowing you the create a new site or restore a backup. Check this post on some tips on how to optimize your controller or how to add the access points.

Keeping the Unifi Controller up to date

It’s important to keep your network products up-to-date. New firmware contains important security fixes, fixes bugs in the software and can enhance the performance of a device. Check out this post on how to update the Unifi Controller and signup to the newsletter. I will drop you an email when there is a new version available!

Common errors

During the installation, you might get an error. It happens sometimes with Linux based systems. You can check the comments below for issue others have run into. One of the problems I had during the installation was this:

unexpected end of file or stream
abort-upgrade: please reinstall previous version

One of the first things you can try is to clean up the downloaded list from APT. This way the files will be downloaded again, solving any issue with corrupt files during the download:

sudo apt-get clean

See also:

Get more stuff like this

IT, Office365, Smart Home, PowerShell and Blogging Tips

I hate spam to, so you can unsubscribe at any time.

91 thoughts on “Install Unifi Controller On Raspberry Pi in 5 min”

  1. Hello there, thinking about buying ubiquiti AP, and ended up here, trying to save some bucks.

    What are the drawbacks to disabling mongoDB? Since ubititi states that “UniFi uses MongoDB to store relevant information about connected devices, Controller configuration, clients, and statistics.”

    Cant i set a limit to how many days the stats are kept? There must be somedrawbacks for sure, no?

  2. The instructions work great also on the new Raspberry Pi 4B, As per the August 22 2019 comment by AlwynAllan I skipped the “haveged” step. Indeed a ‘5 minute or less’ installation!

  3. Hey Guys,

    I am gun shy on this only because of SD card coruption. I know it doesn happen AS often like in the early days but still. Would love to build this, but using USB boot instead. I guess there is always berry boot. Anyone try this?

  4. Worked great for me after my old setup choked on low disk space due to mongodb log files. I used 128 GB this time, but probably overkill.

    As of 2019 raspbian uses the Pi’s hardware RNG by default with rng-tools. I skipped “haveged” and have no slow startup problems. The command “$ xxd -p /dev/random” shows plenty of random entropy.

  5. When using (the earlier version of) this great guide a year ago on a Raspberry Pi, it indeed was a 5-minute affair and it worked flawlessly.
    Now that I wanted to install unifi on another Pi, I cannot get it to work. I followed all the steps on this page.

    When I check the status, unifi appears to be running:
    [email protected]:~ $ systemctl status unifi.service
    ● unifi.service – unifi
    Loaded: loaded (/lib/systemd/system/unifi.service; enabled)
    Active: active (running) since Mon 2019-08-19 21:11:37 UTC; 11min ago
    Process: 608 ExecStart=/usr/lib/unifi/bin/unifi.init start (code=exited, status=0/SUCCESS)
    Main PID: 888 (jsvc)

    When trying to access using https://….:8443 I get the error “Unable to connect”.
    Using “sudo netstat -ntpl” I do not see 8443 listed. I have port 8080 listed, which I use for another application. Even when I kill that application I cannot access the unifi web page.

    In the comments I read that the java version should be 8 or higher, reference is made to 1.8.1_201. I used the installation instructions for the JDK, the version information I get is:
    [email protected]:~ $ java -version
    openjdk version “1.8.0_40-internal”
    OpenJDK Runtime Environment (build 1.8.0_40-internal-b04)
    OpenJDK Zero VM (build 25.40-b08, interpreted mode)

    “40” sounds lower than “201”, could that be the issue? I looked at your page on how to update Java, but that instruction does not work anymore as the software apparently is not available anymore.

    “sudo cat /var/log/unifi/server.log” does not show anything, the log is empty.

    Any suggestions on what else I need to check or fix to make unifi function are appreciated!

    • The output f java -version should be similar:


      openjdk version "1.8.0_222"
      OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1~deb9u1-b10)
      OpenJDK Client VM (build 25.222-b10, mixed mode)

      Did you install OpenJDK with ? :
      sudo apt-get install openjdk-8-jre-headless -y

      • This is what I see:
        [email protected]:~ $ java -version
        openjdk version “1.8.0_40-internal”
        OpenJDK Runtime Environment (build 1.8.0_40-internal-b04)
        OpenJDK Zero VM (build 25.40-b08, interpreted mode)

        Yes, that is exactly the command I used to install OpenJDK.

        • Strange, try this;


          sudo apt clean
          sudo apt update

          Seems like you have an old version over OpenJDK, so the command

          sudo apt-get install openjdk-8-jre-headless -y

          Didn’t work as planned..

          • I have downloaded openjdk version “1.8.0_222” from the web, and manually copied it to directory /usr/lib/jvm/java-8-openjdk-armhf. When I now request the version, it shows this build ‘222’.
            The unifi/server.log file shows a memory error, I have not figured out where this originates from. The log content is rather long:

            [email protected]:~ $ sudo cat /var/log/unifi/server.log
            [2019-08-21T21:38:54,369] WARN system – reload system.properties failed: file not found
            [2019-08-21T21:39:05,692] ERROR system – [exec] error, rc=1, cmdline=[/usr/lib/jvm/java-8-openjdk-armhf/jre/bin/java, -Dfile.encoding=UTF-8, -Djava.awt.headless=true, -Dapple.awt.UIElement=true, -Xmx1024M, -XX:+ExitOnOutOfMemoryError, -XX:+CrashOnOutOfMemoryError, -XX:ErrorFile=/usr/lib/unifi/logs/hs_err_pid%p.log, -jar, /usr/lib/unifi/lib/ace.jar, start]

            Earlier I had a problem with the tmpfs file system being full, purged that so that now at least the log file can show content. I don’t know yet where this memory error stated in the log would originate from…

          • @Rudy @Bram

            Unfortunately the same problem for me. I’m also stuck on the .40 version.

            @Bram, is the manual update working?

            When I look at this feedback it seems that unifi is working…but I can’t reach the interface
            >>>
            systemctl status unifi.service
            ● unifi.service – unifi
            Loaded: loaded (/lib/systemd/system/unifi.service; enabled)
            Active: active (running) since Mwk 2019-08-28 11:08:24 CEST; 15min ago
            Process: 639 ExecStart=/usr/lib/unifi/bin/unifi.init start (code=exited, status=0/SUCCESS)
            Main PID: 855 (jsvc)
            CGroup: /system.slice/unifi.service
            β”œβ”€855 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/java-8-openjdk-armhf -cp /usr/share/…
            β”œβ”€856 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/java-8-openjdk-armhf -cp /usr/share/…
            └─857 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/java-8-openjdk-armhf -cp /usr/share/…
            >>>

          • @Ralf: The copy action appears to load the proper Java version. The unifi service shows to be running. However, the listed warning and errors indicate still something else is wrong. I have not sorted that out yet, will attempt a complete new install later (for now I took a spare Pi to get unifi running on this network).
            Try ‘sudo netstat -ntpl’ to see if Port 8443 is actually listening (in my case it is NOT).
            Also, to see what the full output is, use ‘systemctl status unifi.service –full’, it likely shows further on in the output lines what error it is in your case. That out to give you a hint where else to look.

  6. Hi Ruud,
    I am wanting to give this a go. But how do i know what version of the controller it will install?
    Or does it just pick the latest available form Ubiquiti?

    Clive.

  7. Hi !
    I have follow this tuto but it seems’s that it not work for me….
    When I try to connect on my ip for the raspberry, i have a message that tells me “CONNECITON REFUSED”.
    Can you help me ?

  8. … a year later …

    need to add a comment, unifi will only run on JDK 8, Oracle or OpenJDK. so add a line to the installation script

    sudo apt-get install openjdk-8-jre

    for Buster from July 123 2019 and later….

  9. From various topics got a headache without working results. With this clear explanation you will like the PI again, it works great.
    Thanks,
    Mathijs.

  10. Works great on Buster too! Many thanks for this, I was pulling my hair out trying to follow other tutorials.

  11. Indeed 5 minutes up and running on 3b+ works flawless.
    Enough capacity to handle 2x us8 switch 4x ap 1x security gateway

    Thanks a lot!

  12. Hi,
    I have this issue:
    [2019-05-30T19:28:27,479] INFO system – *** Running for the first time, creating identity ***
    [2019-05-30T19:28:27,484] INFO system – UUID: 47ec6880-4d41-4f5d-a6b3-da3c4a0299fe
    [2019-05-30T19:28:27,497] WARN system – reload system.properties failed: file not found
    [2019-05-30T19:28:27,609] INFO system – ======================================================================
    [2019-05-30T19:28:27,618] INFO system – UniFi 5.10.23 (build atag_5.10.23_11668 – release) is started
    [2019-05-30T19:28:27,620] INFO system – ======================================================================
    [2019-05-30T19:28:27,634] INFO system – BASE dir:/usr/lib/unifi
    [2019-05-30T19:28:28,316] INFO system – Current System IP: 192.168.11.26
    [2019-05-30T19:28:28,319] INFO system – Hostname: irrighino
    [2019-05-30T19:28:32,510] INFO system – Valid keystore is missing. Generating one …
    [2019-05-30T19:28:32,541] INFO system – Generating Certificate[UniFi]… please wait…
    [email protected]:~# tail -f /var/log/unifi/server.log
    [2019-05-30T19:28:27,497] WARN system – reload system.properties failed: file not found
    [2019-05-30T19:28:27,609] INFO system – ======================================================================
    [2019-05-30T19:28:27,618] INFO system – UniFi 5.10.23 (build atag_5.10.23_11668 – release) is started
    [2019-05-30T19:28:27,620] INFO system – ======================================================================
    [2019-05-30T19:28:27,634] INFO system – BASE dir:/usr/lib/unifi
    [2019-05-30T19:28:28,316] INFO system – Current System IP: 192.168.11.26
    [2019-05-30T19:28:28,319] INFO system – Hostname: irrighino
    [2019-05-30T19:28:32,510] INFO system – Valid keystore is missing. Generating one …
    [2019-05-30T19:28:32,541] INFO system – Generating Certificate[UniFi]… please wait…
    [2019-05-30T19:30:18,342] ERROR system – [exec] error, rc=255, cmdline=[/usr/lib/jvm/java-8-openjdk-armhf/jre/bin/java, -Dfile.encoding=UTF-8, -Djava.awt.headless=true, -Dapple.awt.UIElement=true, -Xmx1024M, -XX:+ExitOnOutOfMemoryError, -XX:+CrashOnOutOfMemoryError, -XX:ErrorFile=/usr/lib/unifi/logs/hs_err_pid%p.log, -jar, /usr/lib/unifi/lib/ace.jar, start]
    [2019-05-30T19:30:49,796] ERROR system – [exec] error, rc=255, cmdline=[/usr/lib/jvm/java-8-openjdk-armhf/jre/bin/java, -Dfile.encoding=UTF-8, -Djava.awt.headless=true, -Dapple.awt.UIElement=true, -Xmx1024M, -XX:+ExitOnOutOfMemoryError, -XX:+CrashOnOutOfMemoryError, -XX:ErrorFile=/usr/lib/unifi/logs/hs_err_pid%p.log, -jar, /usr/lib/unifi/lib/ace.jar, start]

    Anyone can help me?

      • I have resolved.
        The issue was about the 8080 port that was occupied by another web server on my raspberry.
        I changed the port and the provisioning was completed successfully.

  13. Hi, I followed all your steps but getting an error when installing the controller.

    It looks like the following (version numbers can be different):

    unifi depends on mongodb-server (>= 2.4.10) | mongodb-10gen (>= 2.4.14) | mongodb-org-server (>= 2.6.0); however:
    Package mongodb-server is not installed.
    Package mongodb-10gen is not installed.
    Package mongodb-org-server is not installed.
    unifi depends on mongodb-server (<< 1:3.6.0) | mongodb-10gen (<< 3.6.0) | mongodb-org-server (<< 3.6.0); however:
    Package mongodb-server is not installed.
    Package mongodb-10gen is not installed.
    Package mongodb-org-server is not installed.

    Any idea?

  14. Very great article, Thank you!
    That is what i am looking for.
    Can I access Raspberry Pi unifi-controller from anywhere?
    We have setup “wifi network” in rural area of Myanmar/Burma.

  15. Great write up. I used it this afternoon to set up my new home Unifi network.
    I saw someone mention that a Raspberry Pi 3 may be needed. I loaded up a model 2. Will I run into any issues? I only have 1 AP and 2 switches.

    • Hi Greg,

      You can use a Raspberry Pi Model 2 without any problems. The amount of devices and clients determine the required processing power and RAM needed. A model 2 can handle one AP and two switches without any issues.

      • So if I were to upgrade to a Model 3, would I just be able to pull the SD card from the Model 2 and have it work without any problems? Or would I be better off rebuilding the whole thing and restoring the database?

  16. I was getting ready to order the Pi but noticed the hardware requirements for Unify Controller changed. Most notable, the 2GB RAM requirement. Is getting the Pi 3 B+ with 1GB RAM still sufficient for running the controller? Thanks!

  17. I followed the guide, but it seems like nothing listens on port 8443. I have octoprint (https://octoprint.org/) running on port 80, and that works fine.

    Assuming this is the correct way to check the status:
    – systemctl status unifi.service

    It looks like the Unifi controller does not start, but there is no indication as to why it fails.
    =====================================
    ● unifi.service – unifi
    Loaded: loaded (/lib/systemd/system/unifi.service; enabled; vendor preset: enabled)
    Active: active (running) since Mon 2019-04-01 14:48:26 BST; 1min 16s ago
    Process: 556 ExecStart=/usr/lib/unifi/bin/unifi.init start (code=exited, status=0/SUCCESS)
    Main PID: 605 (jsvc)
    CGroup: /system.slice/unifi.service
    β”œβ”€605 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt -cp /usr/share/java/commons-daemon.jar:/usr/lib/unifi/lib/ace.jar -pidfile /var/run/unifi.pid -procname unifi -outfile SYSLOG -errfile $
    β”œβ”€606 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt -cp /usr/share/java/commons-daemon.jar:/usr/lib/unifi/lib/ace.jar -pidfile /var/run/unifi.pid -procname unifi -outfile SYSLOG -errfile $
    └─607 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt -cp /usr/share/java/commons-daemon.jar:/usr/lib/unifi/lib/ace.jar -pidfile /var/run/unifi.pid -procname unifi -outfile SYSLOG -errfile $

    Apr 01 14:47:13 octopi systemd[1]: Starting unifi…
    Apr 01 14:48:26 octopi unifi.init[556]: Starting Ubiquiti UniFi Controller: unifi failed!
    Apr 01 14:48:26 octopi systemd[1]: Started unifi.
    =====================================

    I am not so experienced with PI and Raspian yet, so the above is what I have managed to find on different forums, and may be completely wrong.

    Can you guide me 2 how I can troubleshoot my installation?

      • First of all, thanks for the quick reply πŸ™‚

        I rebooted to get the startinfoThe log indicates that initialization goes alright, and then it goes into an error, which repeats every 15 seconds – but not with much information.

        [2019-04-01T21:17:02,881] INFO system – ======================================================================
        [2019-04-01T21:17:02,906] INFO system – UniFi 5.10.20 (build atag_5.10.20_11657 – release) is started
        [2019-04-01T21:17:02,906] INFO system – ======================================================================
        [2019-04-01T21:17:02,912] INFO system – BASE dir:/usr/lib/unifi
        [2019-04-01T21:17:03,082] INFO system – Current System IP: 192.168.1.90
        [2019-04-01T21:17:03,083] INFO system – Hostname: octopi
        [2019-04-01T21:17:09,381] INFO db – waiting for db connection…
        [2019-04-01T21:17:09,888] INFO db – Connecting to mongodb://127.0.0.1:27117
        [2019-04-01T21:17:17,177] INFO db – Connecting to mongodb://127.0.0.1:27117
        [2019-04-01T21:17:17,246] INFO stat – *** Factory Default *** Stat Database exists. Clean it
        [2019-04-01T21:17:17,329] INFO stat – *** Factory Default *** Stat Database exists. Drop it
        [2019-04-01T21:17:20,179] INFO webrtc – WebRTC library version: EvoStream Media Server (www.evostream.com) build v2.2.2 – Gladiator – (built for Debian-8.2.0-armhf on 2018-12-15T00:37:36.000) OpenSSL version: 1.0.2n usrsctp $
        [2019-04-01T21:18:07,338] ERROR system – [exec] error, rc=255, cmdline=[/usr/lib/jvm/java-8-openjdk-armhf/jre/bin/java, -Dfile.encoding=UTF-8, -Djava.awt.headless=true, -Dapple.awt.UIElement=true, -Xmx1024M, -XX:+ExitOnOutOfMemoryError, -XX:+CrashOnOutOfMemoryError, -XX:ErrorFile=/usr/lib/unifi/logs/hs_err_pid%p.log, -jar, /usr/lib/unifi/lib/ace.jar, start]

        I examined /usr/lib/unifi/logs/ which is a link to /var/log/unifi for a detailed error-file, but this directory only contains the server.log and mongod.log.

        An observation from the mongod.log is that it actually shuts down shortly after unifi calls it – is that supposed to be happen. I would expect mongod to be running at all times? (tail on the mongod.log file below).

        Mon Apr 1 21:17:20.566 [conn1] end connection 127.0.0.1:59998 (3 connections now open)
        Mon Apr 1 21:17:22.492 [initandlisten] connection accepted from 127.0.0.1:60006 #5 (1 connection now open)
        Mon Apr 1 21:17:22.497 [conn5] terminating, shutdown command received
        Mon Apr 1 21:17:22.497 dbexit: shutdown called
        Mon Apr 1 21:17:22.497 [conn5] shutdown: going to close listening sockets…
        Mon Apr 1 21:17:22.497 [conn5] closing listening socket: 7
        Mon Apr 1 21:17:22.497 [conn5] closing listening socket: 8
        Mon Apr 1 21:17:22.497 [conn5] removing socket file: /usr/lib/unifi/run/mongodb-27117.sock
        Mon Apr 1 21:17:22.497 [conn5] shutdown: going to flush diaglog…
        Mon Apr 1 21:17:22.497 [conn5] shutdown: going to close sockets…
        Mon Apr 1 21:17:22.497 [conn5] shutdown: waiting for fs preallocator…
        Mon Apr 1 21:17:22.497 [conn5] shutdown: closing all files…
        Mon Apr 1 21:17:22.503 [conn5] closeAllFiles() finished
        Mon Apr 1 21:17:22.503 [conn5] shutdown: removing fs lock…
        Mon Apr 1 21:17:22.503 dbexit: really exiting now

        • UniFi controller will start its own MongoDB instance on the non-standard port, so it looks ok. Only your first log ends with ExitOnOutOfMemoryError, -XX:+CrashOnOutOfMemoryError,. Isn’t it a simple memory related issue? You can check the memory usage with the cmd free -h

          • Thanks for helping me out! Your kind replies sent me in the right direction and forced me to pick up stuff learned many years ago, and almost forgotten. If someone else, is in the same situation as me, the least i can do is share what I did.

            I am running it on a Pi 3 Model B+ with 1 GB RAM – and “free -h”tells me there should 685 MB free, so I should be ok here.

            I was pretty sure – although java coding lies 15+ years back – that -XX:+CrashOnOutOfMemoryError is just a parameter for the jvm, but comment from you sent me on the next step. Just run the command manually and see what happens.

            I took out the command from log file and executed it in the “sudo -i” mode

            /usr/lib/jvm/java-8-openjdk-armhf/jre/bin/java, -Dfile.encoding=UTF-8, -Djava.awt.headless=true, -Dapple.awt.UIElement=true, -Xmx1024M, -XX:+ExitOnOutOfMemoryError, -XX:+CrashOnOutOfMemoryError, -XX:ErrorFile=/usr/lib/unifi/logs/hs_err_pid%p.log, -jar, /usr/lib/unifi/lib/ace.jar, start -bash: /usr/lib/jvm/java-8-openjdk-armhf/jre/bin/java,: No such file or directory

            I then removed the commas between the parameters (they might just be introduced by the logging code) and there was a hit.
            /usr/lib/jvm/java-8-openjdk-armhf/jre/bin/java -Dfile.encoding=UTF-8 -Djava.awt.headless=true -Dapple.awt.UIElement=true -Xmx1024M -XX:+ExitOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError -XX:ErrorFile=/usr/lib/unifi/logs/hs_err_pid%p.log -jar /usr/lib/unifi/lib/ace.jar start
            Port 8080 not available

            Examining what was running on port netstat -nlp | grep 8080 revealed some streamer was running:
            tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 440/./mjpg_streamer

            So i edited /var/lib/unifi/system.properties and changed the port, and now it is running.

            So thanks a lot for the help!

  18. Thank you so much for this write up & reply. You made it so much easier to install Unifi. What are your thoughts of going into raspi-config & adjusting the memory split to 16MB.

  19. I am confused. If using openjdk instead of Oracle Java, in your last command to install UniFi you are also installing Oracle java when you installed openjdk earlier. I thought it was one or the other not both?

    • I understand something has gone wrong with updating the article last week. So Step 3 (now there are 4 main steps πŸ˜‰ ) was still the old part of the article contains the old Java version. I am sorry for the inconvenience! The article is now completely updated. Just formatted my Raspberry Pi again and tested every step to make sure everything is right.

  20. Hi again,
    Nope… it was not a port issue. Service refuses to start…

    [email protected]:~ $ systemctl status unifi.service
    ● unifi.service – unifi
    Loaded: loaded (/lib/systemd/system/unifi.service; enabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Tue 2019-03-26 20:32:10 GMT; 29s ago
    Process: 674 ExecStart=/usr/lib/unifi/bin/unifi.init start (code=exited, status=1/FAILURE)

    Mar 26 20:32:09 raspberrypi systemd[1]: unifi.service: Control process exited, code=exited status=1
    Mar 26 20:32:09 raspberrypi systemd[1]: Failed to start unifi.
    Mar 26 20:32:09 raspberrypi systemd[1]: unifi.service: Unit entered failed state.
    Mar 26 20:32:09 raspberrypi systemd[1]: unifi.service: Failed with result ‘exit-code’.
    Mar 26 20:32:10 raspberrypi systemd[1]: unifi.service: Service hold-off time over, scheduling restart.
    Mar 26 20:32:10 raspberrypi systemd[1]: Stopped unifi.
    Mar 26 20:32:10 raspberrypi systemd[1]: unifi.service: Start request repeated too quickly.
    Mar 26 20:32:10 raspberrypi systemd[1]: Failed to start unifi.
    Mar 26 20:32:10 raspberrypi systemd[1]: unifi.service: Unit entered failed state.
    Mar 26 20:32:10 raspberrypi systemd[1]: unifi.service: Failed with result ‘exit-code’.

    Have been trying a lot of stuff but nothing seems to work…..

    Thanks!

  21. Rudy – please ignore my previous comment; I am such a fool – a simple clearing of my DNS cache on my Mac sufficed…! How stupid πŸ™‚

  22. Hi Rudy
    This is the easiest of all guides I’ve found to get the Unifi controller working on a Pi; however, as others have noted I cannot get my web browser to open a page as expected.

    Indeed I can happily SSH into the IP address for the Pi, but trying to access it via https:// will not work, I am merely presented with “This site can’t be reached 10.0.0.102 refused to connect.”

    I have updated Java as per your additional comment, but still the same problem exists.

    Any ideas?

    Raspberry Pi3 with Stretch

  23. I get “ERR_CONNECTION_REFUSED” in the browser when trying to connect. I also have VNC running on the Pi – don’t know if that might cause a conflict somewhere….

  24. Just a note to those using these instructions – they worked brilliantly the first time, but when I came to upgrade Unifi Controller versions I ran into two issues. First, the java version was out of date and the new version just failed to start and I had to follow the instructions here to update the JDK:

    Guide to update Java also here on LazyAdmin

    I also had an issue where restoring a backup configuration didn’t work. Looking at the logs it seemed that it wanted to use mongodb to do some of the database migration, but these instructions disabled it. I re-enabled it and repeated the process with success.

    Hope that helps someone.

  25. Very nice tutorial, thank you. It worked perfectly on my older Pi 2.
    One error :
    on #4, you have
    sudo apt-get update sudo apt-get install unifi oracle-java8-jdk -y
    it should be
    sudo apt-get update && sudo apt-get install unifi oracle-java8-jdk -y

  26. Errors during installation:

    apt-get update
    ….
    Err http://www.ubnt.com stable/ubiquiti armhf Packages
    301 Moved Permanently [IP: 52.89.117.13 80]
    Ign http://www.ubnt.com stable/ubiquiti Translation-en
    W: Failed to fetch http://www.ubnt.com/downloads/unifi/debian/dists/stable/ubiquiti/binary-armhf/Packages 301
    Moved Permanently [IP: 52.89.117.13 80]

    E: Some index files failed to download. They have been ignored, or old ones used instead.

    and

    apt-get install unifi
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package unifi

  27. Note, default Oracle JRE is 8u65….should probably just forget the oracle JDK in the article.
    {{{
    sudo apt-get install openjdk-8-jre-headless
    }}}

  28. I have the same problem as James.

    I have followed all of the instructions but, when I go to the final stage of viewing this in the browser it shows nothing (I know that the pi is there on the ip address as I can putty into it).

    unifi is already the newest version (5.10.17-11638-1).
    oracle-java8-jdk is already the newest version (8u65).

    What could be the problem?

  29. Rudy,

    You posted on 12th Feb
    “You can follow this guide to update Java on the Raspberry Pi”

    There was nothing to follow.
    Can you re-post what version of java we need to make this work with the latest version of Unifi controller?

    Great article.

    Leo

  30. First of all, I wanted to say “Thank you so much for this”.
    I have used this guide in the past and it worked flawlessly. However, today I am having some difficulties. I have followed all of the instructions (to the best of my knowledge – I am not a command line person!) and everything seems to go well, however, when I go to the final stage of viewing this in the browser it shows nothing (I know that the pi is there on the ip address as I can putty into it). It is like the unifi software is not running on the pi or something similar.
    Any help gratefully received.

      • Hi Rudy,

        thank you for this. I will have time to start from the beginning at the weekend. I did quickly try (I had to install vim as for some reason I did not have this already working – could this have worked with tee?) but did not have the time to start from scratch. I really do appreciate your time on this (as I really don’t want to have to buy a cloud key!). If I run into any more issues I hope it will be ok to post them here.

        James

      • Rudy,

        thank you for your help. I started from scratch and followed all of the instructions but I have run up against “This site can’t be reached 192.168.1.2 refused to connect” when trying to get to the Pi on the browser. I wonder if there is something stopping me browse to the pi (when I can SSH to it if needed)?

        James

  31. I have followed sΓ₯ many guides to install Unifi controller on Raspberry. They all work, but the controller allways stops working after some time. Needs to be restartet daily. After some time its completely broken and you need to start all over reinstalling everything. I have done this fve times now πŸ™

    I guess Raspberry Pi cant handle this?

  32. Thanks a bunch, really useful guide you have there, especially for someone thats new to the command line like me.

    However, I did encounter an error whereby I was not able to update after adding the key. Error message as below:

    [email protected]:~ $ sudo apt-get update
    Hit:1 http://archive.raspberrypi.org/debian stretch InRelease
    Hit:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease
    Get:3 http://www.unbt.com/downloads/unifi/debian stable InRelease
    Err:3 http://www.unbt.com/downloads/unifi/debian stable InRelease
    Clearsigned file isn’t valid, got ‘NOSPLIT’ (does the network require authentication?)
    Fetched 59 B in 1s (29 B/s)
    Reading package lists… Done
    E: Failed to fetch http://www.unbt.com/downloads/unifi/debian/dists/stable/InRelease Clearsigned file isn’t valid, got ‘NOSPLIT’ (does the network require authentication?)
    E: Some index files failed to download. They have been ignored, or old ones used instead.

    Any idea how to go about this?
    Thanks again!

  33. You can simplify installation somewhat and avoid cluttering up your Pi with openjdk by rearranging the command order:

    echo ‘deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti’ | sudo tee -a /etc/apt/sources.list.d/100-ubnt.list > /dev/null
    sudo apt-get -y install dirmngr
    sudo apt-key adv –keyserver keyserver.ubuntu.com –recv 06E85760C0A52C50
    sudo apt-get update
    sudo apt-get install unifi oracle-java8-jdk -y
    sudo systemctl stop mongodb
    sudo systemctl disable mongodb
    sudo reboot

    Apt happily resolves the dependencies of the unifi package and allows installation without grabbing the full openjdk package.

  34. Is it possible to install the Unifi Video controller software as well into the PI along side the Unifi controller software?

  35. Brilliant article thank you!!! Worked perfect first time and saved me alot of typing (by using SSH putty paste) and alot of possible hassle since I am no Linux pro whatsoever (I am an IT Windows guy). I did a for more updates and upgrades than in your article just because but also your command to update the firmware – brilliant.

  36. Thanks for sharing. I followed all the steps and everything seems going fine up to the last step, except that when I go the IP address of the Raspberry, port 8443, it shows a blank page and there’s an error logged in the browser console:

    Uncaught Error: [$injector:modulerr] Failed to instantiate module app-unifi-wizard due to:

    Error: [$injector:nomod] Module ‘app-unifi-wizard’ is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

    Never had a similar issue?

    • In this case I would just reboot and run the install and update steps again. Just to be sure you have the latest versions.

      First try update only:
      sudo apt-get update && sudo apt-get upgrade -y

      Run the install again:
      sudo apt-get install unifi -y

      Of nothing works, then format the SD and start over.

          • Just updating and installing didin’t work, I repeated all the steps except for the initial ones, as I directly flashed a Raspbian Lite image to the SSD (instead of using NOOBS). It initially gave me the same error, but after a few minutes it worked fine, showing the wizard. I’m not sure if it could have worked even the first time, if I only had waited a few more minutes.

  37. I agree great guide. Easy to follow. Thanks a lot.

    Just one thing: to enable SSH in raspi-config you have to go to “Interfacing Options” not “Advanced Options”.

    And don’t forget to do updates!

  38. Great guide. It was quick and easy to copy and paste from instead of having to figure out everything yourself

Leave a Comment