Recent CVEs are a good reason to check how current your UniFi controller is. This guide covers patching the operating system, upgrading the UniFi Network Application, and moving to a fresh CloudSOE image. The image runs on Ubuntu 26.04 LTS on both AWS and Azure. It doesn’t include PHP, so the PHP2Shell advisory doesn’t apply.
Everything on this image is an apt package: unifi comes from Ubiquiti’s apt repository, mongodb-org from MongoDB’s 8.0 repository, and the Java runtime from Ubuntu. That makes in-place upgrades straightforward, as long as you respect the version limits UniFi puts on Java and MongoDB.
What you can upgrade in place
| Component | In place? | How |
|---|---|---|
| Operating system (Ubuntu 26.04 packages, kernel) | Yes | apt update && apt upgrade, then reboot if asked (below) |
UniFi Network Application (unifi) | Yes, with a backup | apt upgrade within your configured release branch. Change the branch to move to a newer release line (below) |
| Java runtime (OpenJDK headless JRE) | Yes, when UniFi asks for it | Install the JRE version the new unifi package depends on (below) |
MongoDB 8.0 (mongodb-org) | 8.0 patch releases only | apt upgrade from the 8.0 repository. Don’t move to a newer MongoDB major or minor version (below) |
You can’t downgrade UniFi: once a newer controller has opened your database, an older version can’t use it. Back up first, every time.
Before you start: back up
1. Snapshot the disk
- AWS: EC2 → Volumes → select the instance’s root volume → Actions → Create snapshot.
- Azure: the VM → Disks → select the OS disk → Create snapshot.
2. Download a UniFi backup (.unf)
A .unf backup restores your whole controller (sites, devices, settings) onto any controller of the same or newer version:
- In the controller, go to Settings → System → Backups and download a fresh backup.
- Check that scheduled auto-backups are turned on. They’re written to
/usr/lib/unifi/data/backup/autobackup.
To copy the auto-backups off the instance from the shell:
mkdir -p ~/unifi-backup
sudo cp /usr/lib/unifi/data/backup/autobackup/*.unf ~/unifi-backup/
sudo chown -R "$(whoami)" ~/unifi-backup
Then, from your workstation:
scp -r ubuntu@<controller-ip>:~/unifi-backup ./unifi-backup # Azure: use your admin username
Update the operating system
sudo apt update
sudo apt upgrade
Because unifi and mongodb-org come from apt repositories, apt upgrade can also update the controller and MongoDB. Read Upgrade UniFi Network and download a .unf backup before you run it. To patch only the OS for now, put a hold on the controller packages first (see Held packages).
Check whether a reboot is needed (usually after a kernel update):
[ -f /var/run/reboot-required ] && cat /var/run/reboot-required
sudo reboot
After a reboot, the unifi and mongod services start on their own. The one-time unifi-firstboot service does not run again, because its marker /var/lib/unifi-firstboot.done already exists. The UI takes a minute or two to come back, and devices reconnect by themselves.
Automatic security updates
The CloudSOE build leaves Ubuntu’s standard unattended-upgrades setup as it is. Ubuntu cloud images normally have it turned on for security updates, but it never reboots for you. By default it only installs updates from Ubuntu’s own repositories, not from the Ubiquiti or MongoDB repositories, so it won’t upgrade the controller behind your back. Check it with:
systemctl status unattended-upgrades
cat /etc/apt/apt.conf.d/20auto-upgrades
Held packages
The image doesn’t hold any packages. You can add holds yourself to keep the controller at its current version while you patch the rest of the OS:
apt-mark showhold # what is held now
sudo apt-mark hold unifi mongodb-org mongodb-org-server
sudo apt-mark unhold unifi mongodb-org mongodb-org-server # when you're ready to upgrade
Don’t leave the controller held for long. UniFi releases include security fixes too.
Don’t run an in-place release upgrade (do-release-upgrade) on this image. To move to a newer Ubuntu release, use a fresh image.
Upgrade UniFi Network
Know what you’re running
dpkg -l unifi | tail -n 1 # installed controller version
cat /etc/apt/sources.list.d/100-ubnt-unifi.list # which UniFi release branch apt follows
mongod --version | head -n 1 # MongoDB
java -version # Java runtime
cat /etc/cloudsoe-support.txt # CloudSOE image build and version
Upgrade within your release branch
The image’s apt source (/etc/apt/sources.list.d/100-ubnt-unifi.list) points at whichever suite had packages when the image was built: Ubiquiti’s stable pointer when it was published, otherwise the newest numbered release branch (for example unifi-10.4). apt upgrade picks up fixes from that suite:
apt-cache policy unifi # installed vs candidate version
sudo apt update
sudo apt install --only-upgrade unifi
The controller restarts as part of the package upgrade and opens its database with the new version. Allow a few minutes, then check everything works.
Move to a newer release branch
Ubiquiti publishes each release line as its own suite (unifi-10.4, unifi-10.5, and so on). Their stable suite is a pointer that sometimes moves to a new branch before that branch has any packages. While that’s the case, a source pointing at stable finds no unifi package at all.
- Check which branch
stablepoints to, and whether that branch has packages yet. A non-zero size on thePackagesline means the branch is published:
curl -fsSL https://dl.ui.com/unifi/debian/dists/stable/Release | grep '^Codename'
curl -fsSL https://dl.ui.com/unifi/debian/dists/unifi-10.5/Release | grep 'ubiquiti/binary-amd64/Packages$'
- Read Ubiquiti’s release notes for the new version, and download a
.unfbackup. - Check what the new package requires. The
Dependsline names the Java runtime and the MongoDB versions it accepts:
curl -fsSL https://dl.ui.com/unifi/debian/dists/unifi-10.5/ubiquiti/binary-amd64/Packages \
| awk '/^Package: unifi$/{f=1} f&&/^Depends:/{print; exit}'
- Switch the source to the new branch and upgrade (replace the branch names with yours):
sudo sed -i 's/ unifi-10.4 / unifi-10.5 /' /etc/apt/sources.list.d/100-ubnt-unifi.list
sudo apt update
sudo apt install --only-upgrade unifi
If the .list file says stable, you can leave it there, as long as apt-cache policy unifi shows a candidate. If there’s no candidate, pin the file to the newest published branch as shown above.
Java
Ubiquiti moves UniFi to a newer Java every few releases (17, then 21, then 25 so far). If a new unifi package needs a Java version you don’t have, install the headless JRE for that version from Ubuntu before upgrading. Otherwise apt may satisfy the dependency with a full JDK:
sudo apt install openjdk-25-jre-headless # use the version from the package's Depends line
sudo apt install --only-upgrade unifi
You can remove the old JRE afterwards, once the controller runs fine on the new one.
MongoDB
MongoDB is the classic UniFi pitfall. Each UniFi release only supports a range of MongoDB versions. The current packages, for example, require MongoDB at least 3.6 and below 8.1. The image installs MongoDB 8.0 from MongoDB’s 8.0-only repository (/etc/apt/sources.list.d/mongodb-org-8.0.list), so apt upgrade only brings 8.0 patch releases. That’s safe.
- Don’t add a newer MongoDB repository (8.2, 9.x and so on) until the
unifipackage’sDependsline allows that version. Otherwise UniFi refuses to install or start. - Never skip MongoDB versions. MongoDB major upgrades have to go one release at a time, with feature-compatibility steps in between. When UniFi does support a newer MongoDB, the low-risk route is a fresh CloudSOE image plus your
.unfbackup. The backup carries your configuration, not the database files, so no in-place MongoDB migration is needed.
Move to a fresh CloudSOE image
A fresh image gets you a current controller, current Java and MongoDB, and a newer base OS, without migrating any of them in place. The .unf backup does the heavy lifting.
1. Back up the old controller
Download a fresh .unf backup (Settings → System → Backups) and copy it to your workstation, as described in Before you start. Note the old controller’s version: the new controller must run the same or a newer version to restore it.
2. Launch the latest image
Launch a new instance from the current CloudSOE UniFi Network listing: AWS guide or Azure guide. Open the same ports as on the old controller.
3. Restore the backup
Browse to https://<new-ip>:8443. In the setup wizard, choose the option to restore from a backup and upload your .unf file. If you’ve already completed the wizard, use Settings → System → Backups → Restore instead. The controller restarts with your sites, devices and settings.
4. Point your devices at the new controller
Your devices still send inform traffic to the old address. Pick one:
- Move the address (best). On AWS, move the Elastic IP from the old instance to the new one (EC2 → Elastic IPs → Associate). On Azure, move the static public IP to the new VM’s network interface. If your inform host is a DNS name, update the DNS record instead. Devices reconnect with no other change.
- Re-inform the devices. If the address has to change, set Settings → System → Advanced → Override Inform Host on the new controller to its new address. Then SSH to each device and point it at the new controller:
set-inform http://<new-ip>:8080/inform
Adopted devices use the device SSH credentials from your controller settings, not ubnt/ubnt. Because the restored controller already knows the devices, they reconnect without being adopted again.
5. Retire the old instance
Once every device shows as Online on the new controller, stop the old instance. Stopping it keeps devices from flapping between two controllers. After a few days, terminate or delete it, and clean up the snapshots you no longer need.
Check everything works
On the instance:
sudo systemctl status unifi mongod
dpkg -l unifi | tail -n 1
sudo tail -n 50 /usr/lib/unifi/logs/server.log
From your own machine (an Azure VM often can’t reach its own public IP), check the controller’s status endpoint. The reply should contain "up":true:
curl -sk https://<public-ip>:8443/status
Finally, log in to the UI and confirm your devices show as Online and the controller version is the one you expected. A STUN warning means UDP 3478 is blocked somewhere on the path.
Next steps
- Configure UniFi Network: file locations, services, ports and inform-host details
- Tips & tricks: backups, adoption troubleshooting and hardening