> Markdown version of https://tuna.am/en/docs/troubleshooting/errors/token-expired/. 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.

# Token expired

```text
FATA[12:00:00] Token expired
  Code: AuthorizationRequired
  Request ID: 3e7d0b92a5f41c68d2e9b0a7f6c31d45

```

A variant of the message is `Token deleted`. If the key was deleted while the tunnel was running, the error appears on reconnect:

```text
FATA[12:00:00] Failed to get connection settings: Token deleted
  Code: Unauthorized
  Request ID: b81c4f07e2d96a35c0f7e1b4a9d26083

```

tuna CLI and Tuna Desktop show this error. The client doesn't reconnect and exits right away. A background service logs the error with the note `the token was revoked or does not exist, reinstall the service with a valid token` and doesn't restart: restarting with the same key won't help.

## Cause

The server knows this API key but no longer accepts it:

* `Token expired` — the key's expiration date, set when it was created, has passed;
* `Token deleted` — the key was deleted in the dashboard or with `tuna api-key delete`. `tuna service uninstall` also deletes the service key.

## What to do

1. Create a new [API key](https://my.tuna.am/api_keys?lang=en) with the Run tunnels permission.
2. Replace the old key wherever it's stored: in CI secrets, the `TUNA_API_KEY` variable, or the config file via `tuna login --with-api-key`.
3. If a background service shows the error, install it again: `tuna service install` issues a new key for the service. See [Running in the background](https://tuna.am/en/docs/tunnels/guides/service.md#service-key).
4. Your own computer doesn't need a key: log in with `tuna login`.

Learn more about keys in [Sessions and API keys](https://tuna.am/en/docs/guides/sessions-and-api-keys.md).
