[BUG] Claude Code fails to login via the Anthropic Console in VSCode when using devcontainers

Status Fixed / completed
Maintainer reply None cached
Activity 4 comments · opened Dec 18, 2025 · closed Jan 4, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

I am trying to use the Claude Code extension in VSCode with a devcontainer. When I try and login via /login, it prompts me to select a login method. When I select Anthropic Console, I authenticate, however when I try and use the Claude Code extension window it fails with Invalid API key · Please run /login. This happens in a loop. Note, this doesn't happen for me when not using a devcontainer.json setup.

What Should Happen?

I should be able to login to Claude Code with /login from within the container setup by the devcontainer.json file.

Error Messages/Logs

Here is what I see in the VSCode output window:


2025-12-18 21:31:10.956 [info] From claude: 2025-12-18T21:31:10.956Z [DEBUG] Getting matching hook commands for UserPromptSubmit with query: undefined
2025-12-18T21:31:10.956Z [DEBUG] Found 0 hook matchers in settings
2025-12-18T21:31:10.956Z [DEBUG] Matched 0 unique hooks for query "no match query" (0 before deduplication)

2025-12-18 21:31:10.967 [info] From claude: 2025-12-18T21:31:10.966Z [DEBUG] FileHistory: Making snapshot for message 6e3e397b-d1e9-4974-a80c-89081f7cf5a0

2025-12-18 21:31:10.967 [info] From claude: 2025-12-18T21:31:10.967Z [DEBUG] FileHistory: Added snapshot for 6e3e397b-d1e9-4974-a80c-89081f7cf5a0, tracking 0 files

2025-12-18 21:31:10.986 [info] From claude: 2025-12-18T21:31:10.986Z [ERROR] Error streaming, falling back to non-streaming mode: Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted

2025-12-18 21:31:10.994 [info] From claude: 2025-12-18T21:31:10.989Z [ERROR] Error in non-streaming fallback: Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted
2025-12-18T21:31:10.989Z [ERROR] "Error: Error: Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the \"X-Api-Key\" or \"Authorization\" headers to be explicitly omitted\n    at validateHeaders (/$bunfs/root/claude:811:1013)\n    at buildHeaders (/$bunfs/root/claude:811:8516)\n    at async buildRequest (/$bunfs/root/claude:811:7582)\n    at async makeRequest (/$bunfs/root/claude:811:3410)\n    at processTicksAndRejections (native:7:39)"

Steps to Reproduce

  1. Setup a new project with a .devcontainer/devcontainer.json file e.g.:
{
  "name": "Python Dev Container",
  "build": {
    "dockerfile": "../Dockerfile"
  },
  "customizations": {
    "vscode": {
      "extensions": [
        "ms-python.python",
        "ms-python.vscode-pylance",
        "anthropic.claude-code"
      ],
      "settings": {
        "python.defaultInterpreterPath": "/usr/local/bin/python",
        "python.linting.enabled": true,
        "python.formatting.provider": "black"
      }
    }
  },
  "forwardPorts": [8000],
  "postCreateCommand": "pip install -r requirements.txt",
  "remoteUser": "root"
}
  1. Open Claude Code extension
  2. Try and login via /login

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.72 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

4 Comments

github-actions[bot] · 10 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/5244
  2. https://github.com/anthropics/claude-code/issues/8002
  3. https://github.com/anthropics/claude-code/issues/5369

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

JohnUiterwyk · 10 months ago

i also see this issue. What worked for me was to first install the cli extension (used the standalone exec), uathenticate with that, then install the vscode extension. After that it seemed to persist the auth

mikeengland · 9 months ago
i also see this issue. What worked for me was to first install the cli extension (used the standalone exec), unathenticate with that, then install the vscode extension. After that it seemed to persist the auth

Hi John - Thanks.

Managed to get this working by mounting my local host's claude dir into the container to avoid it losing the auth after a restart.

  "mounts": [
    // This maps your local Claude config to the container
    "source=${localEnv:HOME}/.claude,target=/home/vscode/.claude,type=bind"
  ],

This seems to have fixed the issue!

github-actions[bot] · 9 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.