Only in December for LazyAdmin readers: Get 20% discount on your first invoice of Cloudways hosting with code LA20. Read more here

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.

Unifi Controller on Raspberry Pi

I have updated this article in Oktober 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:

  • Raspbian Stretch Lite (direct download link) – we don’t need the desktop
  • Rufus – to install Raspbian on the MicroSD card
  • Advanced IP Scanner – to find the IP address of the PI
  • Putty – to connect to the Pi with SSH

Step 1 – Getting the Raspberry Pi up and running

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

Install raspbian in SDCard with Rufus
  1. First, make sure you select your MicroSD card (check the size and drive letter!)
  2. Click on Select and select the downloaded 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 waste your time trying if you have the same, just follow the Alternative way to enable SSH below.

Add new text file ssh to the SDCard

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 startup.

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 2. SSH 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 address, but let’s assume 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.

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 your 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 installing the Unifi Controller on the Pi

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. Go to the Ip address you set earlier (for example 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.

Make sure you backup your Unifi Controller properly. Updates can brick your controller or even Pi, so the best solution is to backup your controller to a cloud storage, like Dropbox. You can read this article on how-to set it up (it only take another 5 minutes πŸ˜‰ )

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 for 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 issues 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

You probably also like the following articles:

Get more stuff like this

IT, Office365, Smart Home, PowerShell and Blogging Tips

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

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

  1. Hi everyone,

    how can I select an older firmware during installation. With the above procedure the current one is always loaded from the Unifi homepage. What must be changed in the procedure?

    Thanks!

  2. Made another install on the latest OS release. The instructions (as always) are great. One minor thing has changed in a recent OS release – the ‘Memory Split’ option has moved in the Pi Software Config Tool. It was under ‘7 – Advanced Options’, now it can be found under ‘4 – Performance Options’, it is then the second option (P2 GPU Memory).

  3. Hi,

    Fantastic guide, tried using others but yours worked spot on and indeed in 5ish minutes. Installed on a RPi 4 and working like a dream.

    Loved the extra tip, re memory management to gain extra space when not using GUI.

    Installing a RPi cluster now, for my Home automation; Pi Hole and Unify. But getting the base system was so much easier than I expected.

  4. Installed on raspberry 2 and on 3b and model 4B but always the same when I want to log in on 192.168.99.118:8443
    Bad Request
    This combination of host and port requires TLS.

    Several times start again wit a clean install and n0 errors.
    What to do now

  5. Hello,
    today the SD card died on my Pi, and my latest backup that I downloaded off the pi was from a month ago… so I have a lot of work with new sites to re-adopt.

    Since the Pi, has USB connectors… will it be possible to insert a USB thumdrive to the PI and have the backup on this external USB drive ??

    anyone with ideas ?
    I which it could email the backup

  6. Hello,
    Today I was adding a client site to my controller on the Pi.
    all went well, exept at the end when I was wraping up and closing the job, I realized that my Controller was unreachable, not even locally it comes up.

    since 1PM til 4:00 PM during the installation it was reachable and working, and now I don’t have access to it.

    the worst part is that my backup doesn’ include the site/job I did today.

    Any ideas or pointers are greatly appreciated.
    maybe my controller ran out of space ? I have to go to the office tomorrow, and check, bult also appreciate how can I release / delete files if this is the case so it comes up again ? it is the only thing that occrurs to me.

    I wanted to get a heads up, as tomorrow will look at the log files and follow up on this post

    my controller is on version 5.12.35 and my last backup was of yesterday.
    I haven’t upgraded as I see that the upgrade instructions there are a lot of “if you get this error, then”
    so usually, I dump a backup and do a reinstall.

    • Where do you have the Pi running? You say you can’t reach the controller, but do have still access to the Pi? And what is the status of the unifi service on the Pi?

  7. Hello, I moved to a Pi following these instructions and so far so good. But today I wanted to add a new site to my controller, and I get an simple error adding site, and it doesn’t add it. are there restrictions ?
    My controller has 20 sites, and to my understanding there is no limit on the quantity of sites.
    My user is a superadmin
    any help is greatly appreciated.

    • Do you have the latest version running (5.13.29), you can check it in Settings > Controller Settings > Basic. I just tested it on my controller and it working fine. Check also the amount of free space on your Pi, just to be sure. In SSH the command df

  8. I had a UniFi controller on a Raspberry Pi; however, that data is no longer available, so this guide allowed me to build a new one. Thanks for this guide.

    Now that I have it operational, the access points are showing as Managed/Adopted already. (by the old controller that I do not have anymore.) On top of this, those access points are using old firmware, 4.0.10.9653.

    Any ideas on how to get the access points to be adopted by this new controller?

    Alternately, how to upgrade those access points manually?

    • you have to do the AP upgrades “step wise” through CLI. 3.x.x -> 4.0.1 -> 4.x.x.

      That usually works for me when an AP wont take the update. all of the past releases are on the UI site. also I have found that it takes the update smoothly if you cache the updates in the controller (its in the settings)

  9. Thanks very much for the guide! Followed all steps to the letter but upon attempting to access the controller, I get an ERR_Connection_Refused error message (This site can’t be reached. 192.168.1.210 refused to connect.) in my browser. I can still access the Raspberry Pi Model B via PuTTY with no issue. Looked at similar comments and attempted fixes to no avail.

    With a new install (no errors encountered), I am using a wired connection, connected to a BT Home Hub 6 router (IP Address: 192.168.1.254). I am using the following IP configuration.

    #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.254
    static domain_name_servers=192.168.1.254 1.1.1.1 fd51:42f8:caae:d92e::1

    Any advice on how I should proceed? Thanks in advance.

      • Haveged is running but have managed to get working by adding Port 8443 to end of URL. i.e. https://192.168.1.210:8443/

        Do you think a 1st generation raspberry pi model B+ would be able to run pi hole as well? If not would a 4th generation rapsberry pi with 1gb RAM be overkill? Heard a Raspberry Pi Zero encounters problems?

        Thanks again for the guide!

        • Ah, the port number totally overlooked that in your first comment.

          I have a model 3 running and in the last couple of months I find it particularly slow when loading the controller. So I don’t think a 1ste gen will run smoothly after a while. A Raspberry Pi 4 is something I am looking into as well to replace my current model 3. And for the money, I would go for the Raspberry Pi 4 – 2GB RAM, only $2 more.

  10. Hi, I will cut straight to the chase. I have followed and successfully installed the controller on my Raspberry Pi 2B with your guide. I thought I would get a head start of configuring my raspberry pi so when I get my router and switch I can just connect it straight. I’ll attach a network diagram link for a better idea https://bit.ly/3bnumVT

    Currently, I have my Raspberry Pi 2B setup/configured with my ISP router/modem. Now that I have all my gear, would I run into issues when connecting it with my usg3 and switch or do I need to start from scratch again? In reference to step #3 below which I have followed, can I or would I have an issue now setting it up with Usg 3 or would it work? I’m connecting with Cat6a poe cable which is on the way, so I will use cat 5e, for now, to set things up. Please advise what is the best course of action.

    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

    • The only problem you are going to run into is the different IP Range. Currently, the local range is 192.168.0.x, when you connect the USG, the local network will change to 192.168.1x (according to your diagram). So you will have to re-configure your Pi, and access points.

      An option is to keep your local range 192.168.0. and give your modem and USG an IP address in the range 192.168.1.x. This way you won’t have to change anything to your local network.

    • Hi, I’ve purchased Rpi 4B with 32GB even bought RPI PoE Hat and rasbian lite buster Feb 2020 version. This Linux worked perfectly fine with my old Rpi 2B.
      The issue here is, when I power up my Rpi 4b. I cannot get an IP nor I can access ssh. The ethernet cable is connected but I can’t discover it neither on Angry Scanner and Advance IP. I’m trying with ethernet cable. I heard this is an issue for all Rpi 4B? I spend entire day trying to figure out. I can’t discover it and therefore I can’t ssh due to I don’t have an IP .

      Please help.
      Thank you in advance πŸ™‚

      • I think the quickest way to determine the issue is to connect a monitor (TV screen) and keyboard. This way you can use the local terminal/CLI to see what IP Address it has or what the network settings are.

  11. Hi I followed your advice from my previous question and now everything works, thanks.
    I have a question: looking in the controller I have not found how to plan the restart of the AP for example every day at a certain time or for example on Monday, Wednesday and Friday at 1:00 at night …
    I was wondering, why hasn’t a planned AP restart been expected when it is known that if for a certain period they are not restarted, they lose performance?
    I guess you have to do a cron with the reboot information … unfortunately I’m not very Linux expert, could you help me? Thanks

    • /* it is known that if for a certain period they are not restarted, they lose performance? */

      How is this known? This might have been true years ago, but there have been a lot of firmware updates, and I figure if I’m up to date I’m good. Plus I’ve never noticed the above effect. I’ve got clients with hundreds of days uptime and never heard this complaint, and my own systems never seem to be slowing over time…

      • Hi, sorry for the late reply. Yes I confirm you, I always update all devices (AP, USG, Switch etc.) to the latest firmware and yet if at least once a month (and often less) they do not restart, they lose their performance. I have an AP Mesh at home and if I don’t restart it at least once a week, I notice slowdowns and yet I have the fiber at 200Mbps: as soon as I restart the AP everything goes fast, this thing is frankly very stressful !!! I can think that I may have enabled some option that creates some problems, could you give me some advice or maybe post screen shots on how to best set up the wifi devices?
        In any case, could you help me plan the reboot of the devices? Unfortunately Ruud did not answer me. Thank you

          • Obviously I am talking about UniFi AC Mesh devices (not pro) and not about Mesh technology …

        • That said, I’ve used python and pexpect to ssh into a UniFi switch and power-cycle the PoE to a switch port, so you could probably use that to log into an AP and reboot it. There are a lot of moving parts, though (unless you want to assign static IPs you have to be able to find the network name of the AP, for instance), but it’ll run on the Pi that’s running the controller. Email hardware at compusmiths dot com for details, this discussion doesn’t really belong here…

  12. Hi, with these simple steps extract from Domoticz manual, i was solved the problem and both works. Regards.

    To start Domoticz automatically when the system starts perform the following steps:
    sudo cp domoticz.sh /etc/init.d
    sudo chmod +x /etc/init.d/domoticz.sh
    sudo update-rc.d domoticz.sh defaults

    Edit the startup script and change the USERNAME, DAEMON and DAEMON_ARGS parameters to reflect your current settingssudo

    vi /etc/init.d/domoticz.sh
    USERNAME=piDAEMON=/home/$USERNAME/domoticz/$NAMEDAEMON_ARGS=”-daemon -www 8080–sslwww 443″If you want to use another web interface port change:DAEMON_ARGS=”-daemon -www 8099–sslwww 443″

    sudo reboot

  13. ok, I finally got this working on my pi (which is still on Jessie, I need to upgrade…)

    When following this guide, java would fail to start with errors in /var/log/unifi/server.log like this:

    “`
    [2020-04-06T03:47:03,319] ERROR system – [exec] error, rc=141, cmdline=[
    /usr/lib/jvm/java-8-openjdk-armhf/jre/bin/java, -Dfile.encoding=UTF-8, -Djava.aw
    t.headless=true, -Dapple.awt.UIElement=true, -Xmx1024M, -XX:+ExitOnOutOfMemoryEr
    ror, -XX:+CrashOnOutOfMemoryError, -XX:ErrorFile=/usr/lib/unifi/logs/hs_err_pid%
    p.log, -jar, /usr/lib/unifi/lib/ace.jar, start]
    “`

    I cobbled together that commandline (removing the commas) and ran it myself and saw the problem was the flags “-XX:+ExitOnOutOfMemoryError, -XX:+CrashOnOutOfMemoryError” – IIUC these were added in a later version of java8. If I manually removed these flags and ran the command it worked – so I knew it was at least possible.

    I tried installing oracle via the webupd8team repo but as noted elsewhere this is no longer possible due to a licensing change.

    So, my next step was trying to figure out how to get jsvc to stop passing those flags, but that completely escaped me. I debated writing a wrapper that would remove them and exec the real java, but was worried about unintended consequences (especially if I used a shell script). So, I called it a night.

    When I got up today I decided I’d just download JDK from Oracle manually, but then I thought I’d give openjdk one more try. I used the instructions here: https://qiita.com/PINTO/items/612718c0ce4f1def6c6e

    I had to remove “Release” from the sources.list line (deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ buster main Release). I also changed `buster` to `stretch` (oops, I forgot what version I was running, but it worked anyways). Then I was able to install that and had an updated java:

    “`
    java -version
    openjdk version “1.8.0_242″
    OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
    OpenJDK Zero VM (AdoptOpenJDK)(build 25.242-b08, interpreted mode)
    “`

    alas, the unifi init script doesn’t know where to find it. there are probably better fixes (maybe removing the old openjdk would work, since it does try to do something with `update-alternatives –query`) but I just hacked it so the new thing was the first thing it considered.

    “`
    # diff -u /etc/init.d/unifi.ORIG /etc/init.d/unifi
    — /etc/init.d/unifi.ORIG 2020-04-06 16:12:53.018115651 -0400
    +++ /etc/init.d/unifi 2020-04-06 15:44:34.621342131 -0400
    @@ -24,6 +24,7 @@
    support_java_ver=’8′
    java_list=”
    for v in ${support_java_ver}; do
    + java_list=`echo ${java_list} adoptopenjdk-$v-hotspot-${arch}`
    java_list=`echo ${java_list} java-$v-openjdk-${arch}`
    java_list=`echo ${java_list} java-$v-openjdk`
    done
    “`

    Then, I had some permissions problems with mongodb, which was probably a consequence of me running things manually as root earlier. I fixed it via some chowns found here: https://community.ui.com/questions/Problem-starting-Unifi-Controller/a4461d1e-f333-4cf3-b939-30246930b0c3

    “`
    sudo chown -R unifi:unifi /var/lib/unifi/data
    sudo chown -R unifi:unifi /usr/lib/unifi/data/db/
    sudo chown -R unifi:unifi /usr/lib/unifi
    “`

    I also had to `rm /var/log/unifi/mongod.log` since that was owned as root.

    Finally – success!

    • FYI, I upgraded my pi to buster via a full reinstall and was able to follow the instructions in my previous post without a problem (I didn’t have the permissions problems I described at the end, I must have messed those up when I was experimenting before). So, in summary:

      * install openjdk 1.8 following the instructions at https://qiita.com/PINTO/items/612718c0ce4f1def6c6e (except in step 3 I had to remove “Release” from the line you add to sources.list)
      * modify /etc/init.d/unifi to look for java in adoptopenjdk-$v-hotspot-${arch}
      – profit!

  14. Hello and thank you for the guide. I installed everything on my Pi3. I followed all the steps but when I started the wizard it didn’t recognize my AP Mesh. I used the controller on the computer, so I exported the site file and imported it into the Pi controller. The import was successful but I don’t understand why it doesn’t authenticate me, i.e. name or password not accepted (but they are the same that I use in the PC and they work there!). I also pressed on “Forgot password” but the email never comes to me …
    Could I know how to reset the password using telnet or editing a file? In Pi I can access it via ftp …
    If you can’t reset your password this way, can you tell me how to get back to the initial wizard? Thank you

    • Hi Roby,

      The username and password are not imported, you will need to login with the credentials that you create during the wizard. But if I understand you correctly, you didn’t follow the wizard to create one. So your only option is to reset the controller. You can either format the SD and start over (takes only 5 minutes πŸ˜‰ ) or remove the files in Raspbian self through SSH:


      apt-get remove --purge unifi
      apt-get remove --purge mongodb
      rm -rf /usr/lib/unifi
      apt-get install unifi

  15. Great guide. Like to know if you have had a chance to upgrade the OS to Buster and where the update could be found?

  16. Excellent guide, worked flawlessly on my Pi 2b. I wish all technical guides were of this quality!

    thank you very much for sharing

    • Maybe don’t disable mongodb? Or install mongodb manually? Sorry I am not familiar with Pine 64. I know that Raspbian comes with its own mongodb, that way we disable it.

  17. Why are you stopping/disabling mongodb, I thought that database is what the controller uses as the backend for logs, storage etc.

    Could you clarify?

  18. And now to update the controller ? When Installed on a windows based system its only click on update, but on RB PI I’ve heard its not. Or is ?

  19. As said a great guide… All worked fine to do the installation

    Question I have is on the logging and the space it will take. Is there no way to use NFS and store the data in e.g. a NAS?

      • Hi Rudy,

        Great, but what will be moved? System.log file I guess but none of the files in the MongoDb? Here there will be a significant amount of data… still you can control this better in the GUI. But I have not a clue on how big thsi will become per AP so to say.

        /Anders

  20. Hi Rudy,

    Great tutorial!
    Just installed the Unifi Controller on an existing Raspberry pi 3 with domoticz already running.

    port 8443 didn’t work out.

    My fix:
    changed Domoticz port

    how to do this?
    log in to your pi with SSH or Putty

    [email protected]:/etc/init.d $ sudo service domoticz stop
    [email protected]:/etc/init.d $ sudo nano domoticz.sh

    change the line
    DAEMON_ARGS=”$DAEMON_ARGS -www 8080″
    to for example:
    DAEMON_ARGS=”$DAEMON_ARGS -www 8099″

    CTRL+X and save the file
    Please note:
    do not use a port in the range 8080 – 8088 as unifi also can use this port and will not start

    [email protected]:/etc/init.d $ sudo service domoticz start
    Warning: domoticz.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.
    [email protected]:/etc/init.d $ sudo systemctl daemon-reload
    [email protected]:/etc/init.d $ sudo service domoticz start
    [email protected]:/etc/init.d $ sudo service unifi status
    ● unifi.service – unifi
    Loaded: loaded (/lib/systemd/system/unifi.service; enabled; vendor preset: enabled)
    Active: inactive (dead) since Tue 2020-01-14 22:11:08 CET; 18min ago
    Main PID: 3306 (code=exited, status=0/SUCCESS)

    Jan 14 22:01:17 pi3 systemd[1]: Starting unifi…
    Jan 14 22:02:22 pi3 unifi.init[3248]: Starting Ubiquiti UniFi Controller: unifi failed!
    Jan 14 22:02:22 pi3 systemd[1]: Started unifi.
    Jan 14 22:11:06 pi3 systemd[1]: Stopping unifi…
    Jan 14 22:11:08 pi3 unifi.init[4280]: Stopping Ubiquiti UniFi Controller: unifi.
    Jan 14 22:11:08 pi3 systemd[1]: Stopped unifi.
    [email protected]:/etc/init.d $ sudo service unifi start
    [email protected]:/etc/init.d $ sudo service unifi status
    ● unifi.service – unifi
    Loaded: loaded (/lib/systemd/system/unifi.service; enabled; vendor preset: enabled)
    Active: active (running) since Tue 2020-01-14 22:30:56 CET; 11s ago

    Please note to use https://: to connect to the unifi controller in your web browser.
    In this example https://192.168.x.x:8099

  21. All,

    After some troubles, Domoticz frequently stopped working on my raspberry I have contacted Ubiquity support and they told me they stopped supporting th controller on a raspberry because of the troubles they have with the controller on a raspberry. So I deinstalled the controller from my raspberry and since then I did not had any trouble anymore with the my domoticz app on the raspberry. I now installed the controller on a NUC with ubuntu and that works fine and is fully supported by Ubiquity.

  22. Congrats – and thanks. Simplest cut paste for me to transfer my mac mini 2009 unifi controller to Raspberry Pi 4. Could not have gone smother!

  23. hello,

    On Dec 11 I ran the df -l command on my Pi controller
    and the /dev/root folder was in use 13%
    today the /dev/root folder was in use at 25% – only 15 days later.
    this is a 64GB memory card.

    I see that my server.log file I have 3 files there of about 100MB
    so even 300MB could not account for that % of the used space.

    mongod.log is 41MB as well.

    so, my question is how can I preserve my precious space, last time the disk was full, I had to reinstall.

    I have the controller to autobackup and only keep 7 files each aprox 15MB is about 110MB, new files replace old files, so this will not using the used space.
    Also set to data retention days to 7 days
    my log level is set to Normal (on device, mgmt, system remote access), which is lowest I could think off.

    Statistics data retention (set at minimum values)
    5 minutes set to 1 hour
    houly set to 1 day
    daily to 31 days
    monthly set to 90 days

    What does the option to “Compact Databse” will do ?

    I will like pointers or ideas on how to prevent the disk space to fill up, and thus I have to reinstall, or how to clean up
    originally I had a 32GB memory, I upgraded to 64GB, I have no plans to install a 128GB, and thus will end up upgrading to bigger and bigger, the idea is to contain the growth/use of space..

    thank you.

  24. Installed today, the tutorial is very easy! Installation went succesfull without warnings. However, it won’t run on the mentioned ports.

    The command service unifi status shows:

    unifi.service – unifi
    Loaded: loaded (/lib/systemd/system/unifi.service; enabled; vendor preset: enabled)
    Active: active (running) since Sun 2019-11-17 16:58:07 CET; 17s ago
    Process: 458 ExecStart=/usr/lib/unifi/bin/unifi.init start (code=exited, status=0/SUCCESS)
    Main PID: 581 (jsvc)
    Tasks: 23 (limit: 4915)
    CGroup: /system.slice/unifi.service
    β”œβ”€ 581 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/java-8-openjdk-armhf/jre/ -cp /usr/share/ja
    β”œβ”€ 582 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/java-8-openjdk-armhf/jre/ -cp /usr/share/ja
    β”œβ”€ 583 unifi -cwd /usr/lib/unifi -home /usr/lib/jvm/java-8-openjdk-armhf/jre/ -cp /usr/share/ja
    └─1671 /usr/lib/jvm/java-8-openjdk-armhf/jre/bin/java -Dfile.encoding=UTF-8 -Djava.awt.headless

    Nov 17 16:56:36 raspberrypi systemd[1]: Starting unifi…
    Nov 17 16:58:07 raspberrypi unifi.init[458]: Starting Ubiquiti UniFi Controller: unifi failed!
    Nov 17 16:58:07 raspberrypi systemd[1]: Started unifi.

    The server isn’t running according to the command netstat -ntpl

    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
    tcp 0 0 127.0.0.1:587 0.0.0.0:* LISTEN 1583/sendmail: MTA:
    tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN 472/vncserver-x11-c
    tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 532/sshd
    tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1583/sendmail: MTA:
    tcp 0 0 0.0.0.0:2812 0.0.0.0:* LISTEN 470/monit
    tcp6 0 0 :::5900 :::* LISTEN 472/vncserver-x11-c
    tcp6 0 0 :::8080 :::* LISTEN 622/domoticz
    tcp6 0 0 :::22 :::* LISTEN 532/sshd
    tcp6 0 0 :::443 :::* LISTEN 622/domoticz
    tcp6 0 0 :::6144 :::* LISTEN 622/domoticz

    When I check system.properties I won’t see any occupied ports by domoticz:

    ## system.properties
    #
    # each unifi instance requires a set of ports:
    #
    ## device inform
    # unifi.http.port=8443
    ## controller UI / API
    # unifi.https.port=8443
    ## portal redirect port for HTTP
    # portal.http.port=8880
    ## portal redirect port for HTTPs
    # portal.https.port=8843
    ## local-bound port for DB server
    # unifi.db.port=27117
    ## UDP port used for STUN
    # unifi.stun.port=3478
    #
    ## the IP devices should be talking to for inform
    # system_ip=a.b.c.d
    ## disable mongodb journaling
    # unifi.db.nojournal=false
    ## extra mongod args
    # unifi.db.extraargs
    #
    ## HTTPS options
    # unifi.https.ciphers=TLS_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA
    # unifi.https.sslEnabledProtocols=TLSv1,SSLv2Hello
    # unifi.https.hsts=false
    # unifi.https.hsts.max_age=31536000
    # unifi.https.hsts.preload=false
    # unifi.https.hsts.subdomain=false
    #
    # Ports reserved for device redirector. There is no need to open
    # firewall for these ports on controller, however do NOT set
    # controller to use these ports.
    #
    # portal.redirector.port=8881
    # portal.redirector.port.wired=8882
    #
    # Port used for throughput measurement.
    # unifi.throughput.port=6789
    #
    #Sun Nov 17 15:30:58 UTC 2019
    debug.device=warn
    debug.mgmt=warn
    debug.sdn=warn
    debug.system=warn
    uuid=03579379-f9d7-4bcf-8239-6670315132e1

    Any help would be appreciated πŸ™‚

  25. Just reinstalled my unifi controller. Followed the tutorial and worked like a charm. Hopefully I have no more issues with running out of disk space in a few months.

    Thank you πŸ™‚

  26. Just followed this on my Pi2. UniFi would not start until I had run sudo apt-get install openjdk-8-jre

    I now have issues with backups not manually running which may be a permissions issues. I’m still working through that one and will report back.

  27. When I stop my domoticz service. I can access the controller page.
    Is it possible to run both on the same PI? Any one any ideas?

    • You will have to change to ports of the Unifi controller.

      Change the file: system.properties in the directory : /data/system.properties

      You can change it to 8081 and 8453 for example.

      • Rudy,

        Thanks indeed I managed to get it working. Changed the port to another because domoticz was already using 8080 on my PI and now I am able to reach the controler over the new port.

  28. Deaar Helpers,

    I followed the procedure completly. All worked but at the end when I try to connect with a browser from an other computer or even with a browser on the PI it self it tells me “connection refused”
    I am already on PI3.

    Here is the output of “sudo netstat -tlnp”:
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
    tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 865/smbd
    tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 558/sshd
    tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 865/smbd
    tcp6 0 0 :::139 :::* LISTEN 865/smbd
    tcp6 0 0 :::8080 :::* LISTEN 582/domoticz
    tcp6 0 0 :::22 :::* LISTEN 558/sshd
    tcp6 0 0 ::1:3350 :::* LISTEN 509/xrdp-sesman
    tcp6 0 0 :::14999 :::* LISTEN 582/domoticz
    tcp6 0 0 :::443 :::* LISTEN 582/domoticz
    tcp6 0 0 :::3389 :::* LISTEN 546/xrdp
    tcp6 0 0 :::445 :::* LISTEN 865/smbd

    What can I do / try to get it working?

  29. Hi Rudy,
    I will appreciate if you can share insides on how to keep the storage on the raspberri pi to a minimum or what to do periodically in order for the SD not to fill up.

    I used a 32GB SD card for the installation, and it filled it up in 4 months,
    now I used a 64GB card, but still don’t want to run into problems like before.

    somehow the controller gave a 500 server error, then when I freed some space, I could no longer authenticate any user, and ended up restarting from the begining with a backup.

    thank you

    • Hi Jimmy,

      Strange that your disk space if filling so rapidly, I never had an issue with that. How is your logo level set? (Maintenance > Services).
      You could try installing the following repo:

      sudo wget https://gist.githubusercontent.com/kburdett/006a16316afa62148b16/raw/unifi_logrotate.d.sh -O /etc/logrotate.d/unifi

      Or change the following file:
      /var/lib/unifi/system.properties

      and add the following line to it;
      log.inform=error

  30. I think I am getting an error due to lack of space.
    how can I clear the logs from putty / terminal ?
    with the pi user I get unathorized access….. what is the root password if we followed your instructions when we originally configured the pi ?
    thank you

      • How can I download the auto backup files on the SD card using putty or any other method
        When I SFtp to the SD card the data folder is a symlink and I cant see it to download

        I am unable to login to my controler, I can start from scratxh and upload a backup from the autobackup. Thank you

        • Hello,
          this is what I did…
          I logged in via SSH and switch to the “su” user, to change the ownership of all files to “pi”, then via SFTP I could download the auto update backups that were on the SD card on the /var/lib/unifi/data/backup/autobackup folder

          I did a clean install, and uploaded the latest recovered backup and was back in business.

          Thank you

  31. Hello, I used your instructions to set a raspberry PI 2 months ago, and it worked like a charm.
    today I tryed to login in, and for some reason, it did not recognized any of the 3 admin user/password setup. – the forgot password option did not work, as we did not received any email to reset the password.

    I did a hard reboot (disconnecting and reconnecting) and now I get
    500: Internal Server Error
    Please to get back to the homepage. (which loops back to the same error message)

    ideas please. I was going to do a backup today.

  32. Hi Ruud

    I’ve got a bit of a problem. I installed unifi controller following your tutorial about a year ago and recently I was getting spammed that my Pi3 is running low on disk space. Since I couldn’t find any solution to fix this I figured I would backup the config and reinstall. However I cannot seem to make it work. I followed the tutorial and when I do “service unifi status” is shows me this:

    unifi.service – unifi
    Loaded: loaded (/etc/systemd/system/unifi.service; enabled; vendor preset: en
    Active: failed (Result: start-limit-hit) since Sat 2019-10-26 20:29:49 BST; 2
    Process: 1055 ExecStop=/usr/lib/unifi/bin/unifi.init stop (code=exited, status
    Process: 947 ExecStart=/usr/lib/unifi/bin/unifi.init start (code=exited, statu

    Oct 26 20:29:49 raspberrypi systemd[1]: unifi.service: Service hold-off time ove
    Oct 26 20:29:49 raspberrypi systemd[1]: Stopped unifi.
    Oct 26 20:29:49 raspberrypi systemd[1]: unifi.service: Start request repeated to
    Oct 26 20:29:49 raspberrypi systemd[1]: Failed to start unifi.
    Oct 26 20:29:49 raspberrypi systemd[1]: unifi.service: Unit entered failed state
    Oct 26 20:29:49 raspberrypi systemd[1]: unifi.service: Failed with result ‘start

    • Most of the time is this error related to a missing or incorrect java version. I just formatted my Pi and re-installed it from step and everything is working great.
      Are you sure you installed OpenJDK?:

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

      • Yeah I am pretty sure.

        [email protected]:~ $ sudo apt-get install openjdk-8-jre-headless -y
        Reading package lists… Done
        Building dependency tree
        Reading state information… Done
        openjdk-8-jre-headless is already the newest version (8u232-b09-1~deb9u1).
        0 upgraded, 0 newly installed, 0 to remove and 18 not upgraded.

        I will try and erase everything once again. The problem I only have TeamViewer access to the Pi and no physical access so I cannot really wipe it clean.

        I will do the “sudo dpkg -P unifi” and “sudo apt-get remove –purge oracle-java8-jdk openjdk-7-jre oracle-java7-jdk openjdk-8-jre” reboot and try again with your tutorial.

  33. From what i am reading this happened to others as well

    I installed controller per instructions and worked very well
    My problem came after first reboot its just stopped working and cant start the controller anymore.

    Is there something what i should do please i am lost !

  34. I tried leaving an update, not sure if it went through so here it is again (again):

    It looks like the pi is not listening on port 8443. Any idea why?

    [email protected]:~ $ sudo netstat -tlnp
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
    tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 416/sshd
    tcp6 0 0 :::8880 :::* LISTEN 492/java
    tcp6 1 0 :::8080 :::* LISTEN 492/java
    tcp6 0 0 :::22 :::* LISTEN 416/sshd

    • I have sort of fixed it. I tried again on a RPi 3 instead of a RPi 2B and that works. My old 2B might simply not be powerful enough.

      Oh and sorry about the spam πŸ˜€

  35. Hey Rudy

    I started from scratch but I ran into the same problem as some of the others β€œThis site can’t be reached 192.168.1.210 refused to connect” when trying to get to the Pi on the browser. I know the IP is correct as I can SSH into it. I have tried what you suggested to the others, but not luck.

    • UPDATE:
      I looks like the pi is not even listening on port 8443. Do you have any idea as to why?

      [email protected]:~ $ sudo netstat -tlnp
      Active Internet connections (only servers)
      Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
      tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 416/sshd
      tcp6 0 0 :::8880 :::* LISTEN 492/java
      tcp6 1 0 :::8080 :::* LISTEN 492/java
      tcp6 0 0 :::22 :::* LISTEN 416/sshd

    • UPDATE:
      It looks like the PI is not listening on port 8443. Any idea why?

      [email protected]:~ $ sudo netstat -tlnp
      Active Internet connections (only servers)
      Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
      tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 416/sshd
      tcp6 0 0 :::8880 :::* LISTEN 492/java
      tcp6 1 0 :::8080 :::* LISTEN 492/java
      tcp6 0 0 :::22 :::* LISTEN 416/sshd

  36. Thanks Rudy for this quick guide.
    I just used in to deploy it on my Pi2 (yes Second edition) and it works like a charm.
    Well, I just have 1 UAC AP and less than 20 devices but it is perfect !
    So thanks again !

    Just have a question, I’m not a Linux expert so could you please share the commands to do a clean shutdown of the environment (processes, databases…)

    Thanks !

  37. 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?

  38. 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!

  39. 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?

    • How about just sticking to the SD install, then image the SD card and do regular backups. I manually upload an encrypted version of my configuration to my Google drive. I’m planning on automating this process, but just haven’t had the time to do it.

  40. 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.

  41. 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.

  42. 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.

  43. 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 ?

  44. … 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….

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

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

  47. 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!

  48. 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.

  49. 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?

  50. 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.

  51. 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?

  52. 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!

  53. 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!

  54. 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.

  55. 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.

  56. 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!

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

  58. 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

  59. 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….

  60. 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.

  61. 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

  62. 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

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

  64. 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?

  65. 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

  66. 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 James,

      I was able to reproduce your issue. It’s related to the new controller version, 5.10.12. I will come with an upgrade guide and solution later to today.

      • 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

  67. 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?

  68. 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!

  69. 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.

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

  71. 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.

  72. 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.

  73. 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!

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

Leave a Comment

262 Shares
Tweet
Pin92
Share170
Share