Troubleshooting
Start with the logs: docker compose logs unifi-mcp. Configuration errors stop the server at startup with a clear message. Controller errors show up in the tool results the assistant sees, and you can usually ask it “what error did you get?”.
The container keeps restarting
Section titled “The container keeps restarting”Run docker compose logs unifi-mcp. The last line names the problem, for example:
| Message | Fix |
|---|---|
UNIFI_URL is required |
Set UNIFI_URL in .env, and check that env_file: .env is in compose.yaml. |
Set either UNIFI_API_KEY or both UNIFI_USERNAME and UNIFI_PASSWORD |
Add credentials. |
API keys are only supported by UniFi OS consoles |
You set UNIFI_CONTROLLER_TYPE=legacy with an API key. Use a local account instead. |
UNIFI_ALLOW_DELETES=true also requires UNIFI_ALLOW_WRITES=true |
Turn on writes too, or turn deletes off. |
Unknown toolset "x" in UNIFI_TOOLSETS |
Fix the typo. The message lists the valid names. |
Could not read UNIFI_API_KEY_FILE (…) |
The secret file isn’t mounted where the variable points. |
MCP_AUTH_TOKEN is required for the http transport … |
Set MCP_AUTH_TOKEN (generate one with openssl rand -hex 32) and send it from your client. Only if something else in front of the server authenticates requests, set MCP_ALLOW_UNAUTHENTICATED=true instead. |
MCP_AUTH_TOKEN must be at least 16 characters |
Use a longer token, for example openssl rand -hex 32. |
MCP_ALLOW_UNAUTHENTICATED=true also requires MCP_ALLOWED_HOSTS … |
List the host names your clients use to reach the server in MCP_ALLOWED_HOSTS, or set MCP_AUTH_TOKEN instead. |
UNIFI_TLS_FINGERPRINT: … is not a SHA-256 certificate fingerprint |
Use the 64-hex-digit SHA-256 fingerprint, with or without colons. SHA-1 fingerprints are too short. |
UNIFI_URL is https, but nothing says how to check the controller's certificate … |
Set UNIFI_TLS_FINGERPRINT to the console’s certificate fingerprint (recommended), UNIFI_CA_FILE to your CA, or UNIFI_VERIFY_SSL=true for a trusted certificate. UNIFI_VERIFY_SSL=false skips the check, as older versions did by default. See Security. |
UNIFI_URL must not contain a username or password |
Remove user:pass@ from the URL and use UNIFI_API_KEY, or UNIFI_USERNAME and UNIFI_PASSWORD. |
Could not read UNIFI_CA_FILE (…) |
The CA file isn’t mounted where the variable points. |
The client can’t connect to the server
Section titled “The client can’t connect to the server”- Is it running?
curl http://<docker-host>:8080/healthshould return{"status":"ok"}. - Right host? The port is published on the machine running Docker. If Docker runs on another machine (for example with
DOCKER_HOST),localhostwon’t work. - Right path? The endpoint is
/mcp, so the URL ishttp://<docker-host>:8080/mcp. 401 Unauthorized: the client isn’t sendingAuthorization: Bearer <MCP_AUTH_TOKEN>, or the token doesn’t match. Watch for stray quotes or spaces in.env.403 Host … is not allowedor403 Origin … is not allowed: add the hostname the client uses toMCP_ALLOWED_HOSTS, or unset it. Browser-based clients send anOriginheader, which must also name an allowed host; for a page on a non-default port, list it ashost:port.405 Method not allowed: the client tried to open an SSE stream withGET. The server is stateless and only acceptsPOST. Make sure the client is set to Streamable HTTP (often calledhttp), notsse.- Connection refused without Docker: run outside Docker, the server listens on
127.0.0.1only. SetMCP_HTTP_HOST=0.0.0.0(and keepMCP_AUTH_TOKENset) to accept connections from other machines.
Login and permission errors
Section titled “Login and permission errors”Login to UniFi controller failed (HTTP 401) / api.err.Invalid
- Check the username and password by logging in to the UniFi web UI with them.
- The account must be local. Ubiquiti cloud and SSO accounts, especially with MFA, can’t log in through the API.
- On UniFi OS, too many failed logins temporarily lock the account. Wait a few minutes.
… failed with HTTP 401/403 … (check credentials and that the account/API key has sufficient permissions)
- With an API key: check it was copied completely and hasn’t been deleted in Settings → Control Plane → Integrations.
- A View Only account can read but not change anything. A write fails with this error even when
UNIFI_ALLOW_WRITES=true.
Certificate and connection errors
Section titled “Certificate and connection errors”Could not reach UniFi controller at https://…: ECONNREFUSED / ETIMEDOUT / ENOTFOUND
- Test from the Docker host:
curl -k https://192.168.1.1. The container uses the Docker host’s network path. - Check the port: UniFi OS uses
443, legacy controllers usually8443, and UniFi OS Server11443. - Hostnames must resolve inside the container. If local DNS names don’t resolve there, use an IP address.
… self-signed certificate … (the controller's certificate isn't trusted …; pin it with UNIFI_TLS_FINGERPRINT …)
Certificate verification is on (UNIFI_VERIFY_SSL=true or UNIFI_CA_FILE), but the controller uses its default self-signed certificate. Turn verification off and pin the certificate instead with UNIFI_TLS_FINGERPRINT, as described in Security: TLS to the controller. Or install a trusted certificate on the controller. If the error mentions ALTNAME, the certificate doesn’t cover the host name or IP in UNIFI_URL; a pin works around that too.
TLS certificate fingerprint mismatch: the controller presented SHA-256 …
The controller’s certificate isn’t the one in UNIFI_TLS_FINGERPRINT. That’s expected after the console renews or regenerates its certificate, for example after an update or a reset. Check the new fingerprint against the console itself (see the openssl command in Security) before you update the variable. If you didn’t expect a change, treat it as a possible interception.
“Redirected” errors
Section titled ““Redirected” errors”… was redirected (HTTP 302) to …; check UNIFI_URL and UNIFI_CONTROLLER_TYPE
UNIFI_URLshould be the bare console URL, such ashttps://192.168.1.1, without/networkor/manage.- If the controller type was detected wrongly, for example behind a reverse proxy, set
UNIFI_CONTROLLER_TYPE=unifi-osorlegacy.
“Endpoint not found”
Section titled ““Endpoint not found””… failed with HTTP 404 … (endpoint not found; it may not exist on this Network application version)
The feature isn’t available on your Network version or hardware, or your site uses the other firewall model. For example, legacy firewall rule tools don’t apply after migrating to zone-based firewall, and the other way round. Network 11 migrates every site, so they never apply there. See Compatibility.
Site errors
Section titled “Site errors”api.err.NoSiteContext or api.err.NoPermission for a site
Tools need the site’s API name, not its display name. Ask “list my UniFi sites” and use the name field (for example default or x7k2pq9d) for UNIFI_SITE or in your questions.
A change didn’t take effect
Section titled “A change didn’t take effect”- The tool returns as soon as the controller accepts a change. Devices then need a few seconds to provision, and clients may reconnect.
- Some field names vary between Network versions. Ask the assistant to fetch the object with
raw: true, compare it with what you expected, and set the right field viaextra. See Compatibility → fields that couldn’t be verified. - If the controller rejected the change, the tool result contains the controller’s message, such as
api.err.InvalidPayload.
Tools are missing
Section titled “Tools are missing”Tools are only registered when they’re allowed:
- Write tools need
UNIFI_ALLOW_WRITES=true, and delete tools also needUNIFI_ALLOW_DELETES=true. - Each tool’s toolset must be listed in
UNIFI_TOOLSETS. - Restart the container after changing
.envwithdocker compose up -d, and reconnect or restart your MCP client so it fetches the new tool list. - Version 0.5.0 listed only three meta-tools by default (
UNIFI_TOOL_MODE=lazy). That mode was removed in 0.6.0, and every enabled tool is listed again. If the server now refuses to start withUNIFI_TOOL_MODE was removed in 0.6.0, deleteUNIFI_TOOL_MODEfrom your configuration and useUNIFI_TOOLSETSto keep the list small (see Keeping the tool list small).
Slow or timing-out tools
Section titled “Slow or timing-out tools”- Some operations are slow by nature: backups, RF scans, large statistics reports and big client lists. Raise
UNIFI_TIMEOUT_MS, for example to120000. - Behind a reverse proxy, raise the proxy’s read timeout too.
- Use
search,fields,limitand toolset filtering to keep responses small (see Narrowing list results).
Still stuck?
Section titled “Still stuck?”Search the existing issues or open a bug report. Include your controller model, Network version, unifi-mcp version (the first log line) and the exact error. Remove any credentials, tokens and public IPs first.