> Markdown version of https://tuna.am/en/docs/troubleshooting/errors/incorrect-token/. Documentation index: [llms.txt](https://tuna.am/en/llms.txt), full text in one file: [llms-full.txt](https://tuna.am/en/llms-full.txt). Any page is available as Markdown: append `.md` to its URL without the trailing slash.

# Incorrect token

```text
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:

```text
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](https://tuna.am/en/docs/troubleshooting/errors/token-expired.md).

## 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](https://tuna.am/en/docs/guides/config-file.md). An old `TUNA_TOKEN` left in the environment overrides even `tuna login`.
2. Compare the key with the list of [API keys](https://my.tuna.am/api_keys?lang=en) 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](https://tuna.am/en/docs/tunnels/guides/service.md).

If the key is correct but the error persists, contact [support](https://tuna.am/en/docs/support.md) and include the `Request ID`.
