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

  1. SSH into any device and run info. When I ran this command I noticed the IP for my old controller was present.

  2. Running set-inform http://currentip only resolves the issue temporarily. If I push another change to a device the inform URL reverts back.

  3. This lead me to believe the old IP was stuck in the database somewhere.

Verifying the issue

  1. ssh to your unifi network appliance
  2. 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>
  1. Switch to the ace database use ace
1> use ace
2switched to db ace
  1. Now we are going to look at 2 fields migrate_inform_url and inform_url in the devices 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" }
  1. 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

  1. Unset the migrate_inform_url
1db.device.updateMany({}, { $unset: { migrate_inform_url: "" } })`
1output
2
3{ "acknowledged" : true, "matchedCount" : 4, "modifiedCount" : 2 }
  1. 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 }
  1. Last I restarted the unifi service service unifi restart

  2. All of my devices have been stable for a week now.