Skip to main content

Incorrect token

FATA[12:00:00] Failed to get connection settings: Incorrect token
Code: Unauthorized
Request ID: 5c1e8a04f7b29d63e0a4b718c92f5d3e

When a tunnel starts, the same cause more often looks like this:

FATA[12:00:00] Unknown token
Code: AuthorizationRequired
Request ID: 9a3f61d0c4e82b57f1d06a9e3c7b4208

tuna CLI and Tuna Desktop show this error when a tunnel starts with an API key or a legacy token. The client doesn't reconnect and exits right away. A background service appends the token was revoked or does not exist, reinstall the service with a valid token to the message and doesn't restart.

Causeโ€‹

The server couldn't find the key you passed. Usually this means that:

  • the key has a typo, or part of it was lost when copying;
  • the variable or flag got the wrong value, for example an empty string from an unset CI secret;
  • the account or team that owned the key was deleted.

The server recognizes a key that was deleted or has expired and responds with a different error โ€” Token expired.

What to doโ€‹

  1. Check where the CLI takes the key from. For tunnels, it checks the sources in this order: the --api-key flag, the TUNA_TOKEN variable, the saved session, the TUNA_API_KEY variable, the config file. An old TUNA_TOKEN left in the environment overrides even tuna login.
  2. Compare the key with the list of API keys in the dashboard. If the key isn't there, create a new one with the Run tunnels permission.
  3. Update the key wherever it's stored: in CI secrets, the TUNA_API_KEY variable, or the config file via tuna login --with-api-key.
  4. Your own computer doesn't need a key: remove it from the environment and log in with tuna login.
  5. Reinstall the service with the new key โ€” see Running in the background.

If the key is correct but the error persists, contact support and include the Request ID.