Troubleshooting
About 1972 words
When a command fails, unifi-cli prints what went wrong, a list of things to try, and the chain of causes underneath. This page explains the failures you're most likely to meet and how to get more detail when the message isn't enough.
Start here
unifi ctx describeThis one command checks the three things most failures come down to: the address, the TLS certificate and the API key. It shows what the current context resolves to, asks the controller for its version and sites, and reports reachable or the reason why not.
If unifi ctx describe works and another command doesn't, the problem is specific to that command, usually a permission or a missing endpoint.
Read an error
$ unifi clients block "Guest-iPhone" --yes
✗ The API key is not allowed to do this.
The client "Guest-iPhone" could not be blocked.
Advice:
• Check that your API key may change the network; read-only keys cannot.
• Use an API key that belongs to an administrator with write access; keys of view-only administrators can
only read.
• Run `unifi login` to switch to a different API key.
Caused by:
→ the controller says: this API key is read-only or may not do thisAn error leads with the most specific thing that went wrong, followed by what you were trying to do. The advice lines are the things to try, most likely first. A "Caused by" section appears when there is an underlying cause worth reading, such as connection refused or a certificate error. When the controller explained its refusal, that explanation is there too, as the controller says: .... HTTP status codes and request paths stay in the log. For failures unifi-cli didn't expect, a last advice line points at the log file.
Errors go to standard error and the exit code is 1.
Read the log
Every request, retry and failure is written to a log file:
unifi config path # shows where it is
tail -n 20 ~/.local/state/unifi-cli/unifi.log | jq .At the default level the log has failures and retries. A request that failed leaves one request failed line with its method, path, status, the number of attempts and the controller's own message; the command failed line after it repeats what you saw on screen. Requests that unifi-cli expects to fail now and then, such as a probe for an endpoint that older Network versions lack, are logged at debug level, so a warning in the log is something that went wrong for you. To see every request with its path, status and duration, run the failing command once more with debug logging:
UNIFI_LOG_LEVEL=debug unifi clients get > /dev/null
tail -n 20 ~/.local/state/unifi-cli/unifi.log | jq -r '[.level, .msg, .method, .path, .status] | @tsv'The request paths tell you which API family a command used: /integration/v1/... is the official API, /api/s/... and /v2/api/... are the internal one. The log holds no API keys, but it does name your hosts and devices.
Connection problems
The TLS certificate is not trusted
✗ The TLS certificate of "https://192.168.1.1/proxy/network" is not trusted.A console ships with a self-signed certificate, which no machine trusts by default. Sign in again and pin the certificate, which trusts exactly the one the console presents now:
unifi login --local --address https://192.168.1.1 --pin-certificate --name homeSigning in again with the same --name replaces the context. The login guide covers the alternatives, --ca-file and --insecure-skip-tls-verify.
The certificate no longer matches the certificate pinned for it
A context that used to work now gets a different certificate from the console than the one you pinned:
$ unifi clients get
✗ The certificate of the controller at "https://192.168.1.1" is not trusted: it no longer matches the
certificate pinned for it.
Advice:
• Stop here until you know why: the controller's certificate may have been renewed or replaced, or someone
may be intercepting the connection.
• Pinned SHA-256 fingerprint:
FF:DD:41:B7:52:6D:57:C0:34:67:28:41:14:B8:33:AB:3E:06:AE:11:7D:52:CF:68:25:29:3A:FC:35:6E:1E:DF.
• Presented SHA-256 fingerprint:
1C:9C:5A:AF:1C:15:FD:A2:84:E8:9A:6E:C4:34:50:D2:FE:B2:11:97:EB:5B:C1:4D:7C:09:86:F9:7D:B2:FA:97.
• Compare the presented fingerprint with the one the console shows for its certificate. Only when they
match, pin the new certificate with
`unifi login --local --address https://192.168.1.1 --pin-certificate`.After a factory reset, a firmware update that renewed the certificate, or a certificate you installed yourself, that's expected. Compare the presented fingerprint with the one the console shows, and pin again with the command from the last advice line when they match. If nothing changed on your side, find out why before you do, because this is also what an interception looks like.
A certificate also has to cover the name you connect to. One issued for unifi.local doesn't match https://192.168.1.1 and can't be pinned for it; use the name in the address.
The controller cannot be reached, refused the connection, or did not answer in time
Check the address first: unifi ctx get shows the controller of each context, and unifi ctx describe its address. UniFi OS consoles listen on port 443 and self-hosted Network Servers on 8443.
For a local context, you have to be on a network that can reach the console, which usually means at home or on the VPN. For a cloud context, the console has to be online and connected to the UI cloud; unifi consoles get shows its status.
A timeout from a cloud context with a healthy console is often the cloud connector being slow. Try again, and if it persists, try a local context to rule out the console itself.
The controller's hostname cannot be resolved
DNS. unifi.local relies on mDNS, which doesn't cross VPNs and routers. Use the IP address, or a name your DNS server knows.
Authentication and permissions
The controller rejected the API key (HTTP 401)
The key is wrong, was deleted, or has expired. Check it where you created it: on the console under Settings → Control Plane → Integrations, or at unifi.ui.com under Settings → API Keys. Then sign in again with the same --name to store a new one.
Two mix-ups produce the same message. A Site Manager key doesn't work with --local, and a console key doesn't work for the cloud sign-in. And if UNIFI_API_KEY is set in your environment, it overrides the stored key of every context, including the ones it doesn't belong to; unifi ctx describe shows stored in the env credential store when that's happening.
The API key is not allowed to do this (HTTP 403)
The key belongs to an administrator who may not make this change, most often a view-only one. Reads work with any key; changes need an administrator with write access to the site.
The API key could not be stored
unifi login puts the key in the OS keychain, and falls back to the credentials file when there is none or when the keychain doesn't answer within three seconds. On Linux the keychain is a Secret Service (GNOME Keyring or KWallet) with an unlocked keyring. The file is ~/.config/unifi-cli/credentials.yaml, readable by you alone. If a half-working keychain gets in the way, UNIFI_CREDENTIAL_STORE=file skips it altogether.
It refuses to read that file when group or others can access it. Fix the mode with chmod 600, and rotate the key, because someone else on the machine may have read it.
Rate limits
✗ The controller is rate limiting requests.The controller, or the cloud connector in front of it, answered with HTTP 429. unifi-cli already retried: read requests get up to three attempts with a growing pause, and honor the wait the server asks for.
When you see this, something is asking too often. The usual suspects are a dashboard with a refresh interval of a second or two, a script that calls unifi-cli in a tight loop, or several of either at once on the same key. Raise the dashboard's interval (unifi config set dashboard.refresh 15s), and in scripts fetch a list once with --output json and filter it locally. The dashboard backs off on its own when it's throttled and says so in its footer.
Older controllers and missing endpoints
✗ The controller does not know "/integration/v1/sites/.../firewall/zones".The official Network API needs UniFi Network 9.0 or newer, and it grew with each release: zone-based firewall, ACL rules and DNS policies arrived later than sites, devices and clients. A controller that predates an endpoint answers 404 for it.
What to do depends on the command.
unifi exportfails on the first kind the controller can't list. Pass--skip-unavailableto export the rest.- For a single subject, there's no workaround short of updating the Network application.
unifi resources get --output wideshows the path behind every kind, which tells you what to look for in the release notes.
The reverse case exists too. Kinds served by the internal API can change shape when Ubiquiti updates the Network application. If a settings field you scripted against is gone after an update, unifi settings describe <key> shows what the controller has now.
A self-hosted Network Server serves the application at the root of port 8443, without the /proxy/network prefix of UniFi OS consoles. Sign in with the full URL including a trailing slash, so unifi-cli uses it as it is: --address https://controller.example.net:8443/.
Usage errors
This action needs confirmation, and no terminal is attached to ask
A command that takes something offline or deletes something was run from a script or a pipe. Pass --yes once you're sure.
No client matches, or "sonos" matches 3 clients
Names are matched against what the controller knows right now. List the objects (unifi clients get), and when a partial name is ambiguous, use the full name, the MAC address or the ID.
The filter refers to the unknown field
Filter fields are the JSON field names, not the column headers: the SIGNAL column is signalDbm. The error lists the valid fields, and --output json shows them on real data.
The output is out of date
unifi-cli caches a controller's site list and version for ten minutes and completion candidates for a minute. If you just created a site or renamed something in the web interface and a command doesn't see it, run it once with --no-cache.
The output looks broken
Garbled boxes or question marks mean your terminal font lacks the glyphs. Switch to 7-bit symbols with unifi config set glyphs ascii.
Wrong colors, such as dark text on a dark background, mean the background detection guessed wrong. Pin it with unifi config set colorScheme dark or light.
A table that's missing columns you expected from --output wide is a terminal that's too narrow: the least important columns are hidden, and a line on standard error says how many. Widen the terminal, pipe the output, or use --output json.
Report a bug
Open an issue on GitHub with:
- the output of
unifi version, - the UniFi Network version from
unifi ctx describe, and the console model, - the command and its full error output,
- the matching lines of the log at debug level.
Read the log excerpt before you post it. It contains no keys, but it does contain names and addresses from your network.
