# Troubleshooting

> Diagnose common problems when using the CLI with adTraces.

## Run the diagnostics

```bash
traces doctor
```

It checks the binary, the local database, credentials, network access to the API and agent hooks.

## The CLI talks to the wrong server

Symptom: login opens traces.com, or uploads go elsewhere. Make sure all three variables are set in the shell that runs the CLI:

```bash
echo $TRACES_HTTP_URL $TRACES_URL $TRACES_API_URL
```

They must all be `https://adtraces.adfactory.app`. You can verify the server with `curl https://adtraces.adfactory.app/api/health`.

## Authentication problems

```bash
traces login --no-browser     # print the URL instead of opening a browser
traces whoami
traces reset --all            # clear credentials, then log in again
```

A 401 from the API means the key or token is missing, expired or revoked. A 403 names the missing scope in its message.

## Agent not detected

- Run `traces setup` again; paths managed by an agent may have changed.
- Check the agent is listed under [Supported agents](/docs/cli/supported-agents).
- Hooks only see the agent's environment, see [Agents](/docs/agents).

## Reset local state

```bash
traces reset            # delete the local database; synced traces stay on the server
traces reset --all      # also credentials
```
