Troubleshooting UniFi Device "Adopting" Loop
Overview
Introduction
I am running unifi devices in my home lab. I noticed my devices were consistanly going into adopting
state. This seemed to happen anytime I would make a change to a device.
Identifying the issue
SSH into any device and run
info
. When I ran this command I noticed the IP for my old controller was present.Running
set-inform http://currentip
only resolves the issue temporarily. If I push another change to a device the inform URL reverts back.This lead me to believe the old IP was stuck in the database somewhere.
Verifying the issue
- ssh to your unifi network appliance
- Connect to mongodb
mongo --host 127.0.0.1:27117
1$ mongo --host 127.0.0.1:27117
2MongoDB shell version v3.6.8
3connecting to: mongodb://127.0.0.1:27117/
4Implicit session: session { "id" : UUID("72df6c06-4432-4716-9ea2-ec18d8f19e77") }
5MongoDB server version: 3.6.8
6>
- Switch to the
ace
databaseuse ace
1> use ace
2switched to db ace
- Now we are going to look at 2 fields
migrate_inform_url
andinform_url
in thedevices
collection in this database.
Show the migrate_inform_url
field for devices.db.device.find({}, { "migrate_inform_url": 1, _id: 0 })
1> db.device.find({}, { "migrate_inform_url": 1, _id: 0 })
2{"migrate_inform_url" : "http://10.10.15.3:8080/inform"}
3{"migrate_inform_url" : "http://10.10.15.3:8080/inform"}
Show the inform_url
field for devices.db.device.find({}, { "inform_url": 1, _id: 0 })
1> db.device.find({}, { "inform_url": 1, _id: 0 })
2{ "inform_url" : "http://10.10.10.231:8080/inform" }
3{ "inform_url" : "http://unifi:8080/inform" }
4{ "inform_url" : "http://10.10.15.3:8080/inform" }
5{ "inform_url" : "http://10.10.10.231:8080/inform" }
- What I found here is a mixture of issues.
- 2 of my devices still had the
migrate_inform_url
field defined. - And one of my devices was using
unifi:8080
for the URL. In my lab DNS is not working so I need to use IPs.
The fix
- Unset the
migrate_inform_url
1db.device.updateMany({}, { $unset: { migrate_inform_url: "" } })`
1output
2
3{ "acknowledged" : true, "matchedCount" : 4, "modifiedCount" : 2 }
- Set the
inform_url
to the correct ip.
1db.device.updateMany({}, { $set: { "inform_url": "http://10.10.10.231:8080/inform" } })
1output
2
3{ "acknowledged" : true, "matchedCount" : 4, "modifiedCount" : 2 }
Last I restarted the unifi service
service unifi restart
All of my devices have been stable for a week now.