Skip to content

ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY set · Claude Code

Quick fix

Run claude daemon stop --any to stop lingering Claude background processes, then restart and resume the session.

Error output
Both ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY set · auth may not work as expected

After switching authentication methods, Claude's background Daemon process may retain the previous authentication state. When first entering a session, the environment contains only `ANTHROPIC_API_KEY` or `ANTHROPIC_AUTH_TOKEN`, but after resuming the session through Agent View, the old authentication variable may be injected again, causing both variables to coexist.

The reporter could no longer reproduce the issue after stopping all Claude background processes, so lingering Daemon state was considered the cause and a temporary workaround. The maintainer said that retrieving and controlling Daemon state is difficult for security reasons and remains under investigation. The issue was eventually closed automatically after prolonged inactivity, without an official fix confirmed by the maintainer.

  1. Exit the current Claude Code session.

  2. Run `claude daemon stop --any` to stop all lingering Claude background processes.

  3. Restart Claude Code and resume the session through Agent View. Run `!env | grep ANTHROPIC` and confirm that the environment contains only the single variable corresponding to the current authentication method.

ToolClaude Code
Version受影响版本 3.16.2
PlatformsWindowsLinux
Can ccswitch automatically stop or restart the Claude Daemon when switching authentication methods?
The reporter suggested adding this process, but the maintainer said that retrieving and controlling Daemon state is difficult for security reasons and is still under investigation.

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.