{"slug": "claude-code-works-in-windows-but-fails-in-wsl", "title": "Claude Code Works in Windows but Fails in WSL", "summary": "Anthropic added an API connectivity section to the claude doctor diagnostic command in Claude Code 2.1.331, giving developers a way to diagnose why the same prompt works in a Windows PowerShell terminal but fails in WSL with \"Unable to connect to API.\" The guide recommends running claude doctor, claude --version and claude auth status --text in both the failing WSL shell and a working PowerShell window, then comparing launch environment, intermediary and destination in that order before reinstalling or signing in again. For WSL 2, Microsoft documents DNS tunneling, automatic proxy propagation and mirrored networking as separate parts of the network route that can explain the divergence.", "body_md": "Claude Code replies in PowerShell. In your WSL terminal, the same prompt dies with “Unable to connect to API.” Before you reinstall or sign in again, run claude doctor in both places. The first difference you see can tell you whether to inspect the Linux install, the company proxy, the certificate chain, or the account route.\n\nAnthropic added an API connectivity section to Doctor in Claude Code 2.1.331. It can report an HTTP status, give an error, or explain why it skipped a test. That gives developers a useful starting point when the same laptop produces two different outcomes. This guide pairs that output with a tiny model request and shows what evidence to hand to IT if the fix belongs to them. [Claude Code release notes](https://github.com/anthropics/claude-code/releases/tag/v2.1.331)\n\nUse the exact launcher that fails. If the error appears in a VS Code terminal attached to a WSL folder, collect the Linux result there. An Ubuntu window opened from the Start menu can load a different shell profile and see different variables. Use your working PowerShell window for the other result. Keep both on the same approved network or VPN while you take the first readings.\n\nIn PowerShell, run these commands. The executable information matters when multiple installs or a wrapper compete for the same name.\n\n```\nGet-Command claude | Select-Object CommandType, Sourceclaude --versionclaude doctorclaude auth status --text\n```\n\nRun the matching checks in the affected WSL shell. type -a can reveal a shell alias, a local Linux install, and an entry inherited from the Windows path. A path under /mnt/c deserves a closer look. Confirm which binary or wrapper the shell actually starts. If two versions are installed, capture both before changing either one.\n\n```\ntype -a claudeclaude --versionclaude doctorclaude auth status --text\n```\n\nRecord the exact error or skip reason and the provider or auth method you expect each launch to use. Read the auth output locally before sharing it, since account and configuration details can identify your organization. A logged-in result describes the auth state reported by that CLI. You still need a model request to verify access to the selected model. [Claude Code CLI reference](https://code.claude.com/docs/en/cli-reference)\n\nCheck the working directory, too. A trusted work repo can supply project settings that a scratch folder lacks. If you move to a scratch folder for the first model test, run it in each environment and capture that change in your notes. Preserve the result from the original launch, since it can show that the failure needs the repo or editor to occur. [Claude Code settings](https://code.claude.com/docs/en/settings)\n\nStart with what the two results prove. Think of Windows and WSL as separate clients that share a keyboard. They can launch different builds, inherit different proxy information, use different trust stores, and present different accounts. If PowerShell uses a subscription and WSL targets your employer’s gateway, the pair tells you two routes behave differently. It takes another test with matching routes to narrow the difference to the Linux environment.\n\nCompare the launch environment, the intermediary, and the destination in that order.\n\nA name resolution error tells you a name lookup failed. Determine whether the error names the API host or the proxy host. If the proxy needs to resolve the destination, local lookup of the API host alone can leave the real problem untouched. With a refused connection, check which host and port the client attempted and whether the approved service is listening. A reset can come from several points along the path, so retain the error and time for the team that can inspect the network logs.\n\nFor WSL 2, Microsoft documents DNS tunneling, automatic proxy propagation, and mirrored networking on supported Windows versions. They address different parts of the route. If the failure is a named lookup, ask about DNS tunneling and the approved resolver setup. If the Windows proxy is missing from WSL, check automatic proxy propagation and the effective proxy settings. Save active WSL work before a restart is needed to apply a managed change. [Microsoft’s WSL networking guide](https://learn.microsoft.com/windows/wsl/networking)\n\nStart with the named error. An unknown issuer under TLS inspection points toward trust or an incomplete certificate chain. A hostname mismatch points toward the identity of the server or intermediary. An expiry error calls for checking the chain and clock. A working Windows browser can trust a root delivered by device management while the Linux distribution or Claude Code launch needs its own approved trust configuration.\n\nAsk your IT team which CA bundle is approved for this route and which component owns it. Anthropic documents NODE_EXTRA_CA_CERTS for adding trusted CAs. If your team uses that setting, use a Linux-visible path, verify it is readable in the WSL shell, and launch a fresh Claude Code process. The fresh launch matters because Claude Code reads these shell variables at startup. Keep certificate verification enabled. [Claude Code enterprise network configuration](https://code.claude.com/docs/en/network-config)\n\nFor the request that produced that status, some component answered at the HTTP layer. That could be the intended service, a forward proxy, or a company gateway. A 407 suggests the proxy wants authentication. A 401 generally calls for a credential check at the component that returned it. A 403 could be an access rule or a proxy policy. Start by identifying the responder with the help of your gateway or network team. Then check the credential or policy for that specific hop. Swapping your Anthropic credential cannot satisfy a proxy’s separate authentication requirement.\n\nA response to a reachability probe gives you limited evidence. A probe and a model call may use different paths or methods. The model call also needs the right account, model, and billing or entitlement. Treat Doctor’s result as one observation and compare it with the short request below. [Claude Code error guidance](https://code.claude.com/docs/en/errors)\n\nSave the skip reason as written. If the section is absent, first verify the executable version and installation channel in that shell. If the reason points to a provider configuration, check the deployment docs for that provider and test the route you use for work. An HTTP request to the public Anthropic API has little bearing on whether your managed provider accepts a signed model request.\n\nThis Bash snippet prints the names of exported variables that are present, even if their values are empty. It leaves credentials and proxy URLs out of the output. Run it in the failing shell, then check any unexpected value privately. The result reflects the environment passed to child processes. Claude Code can also receive values from its own settings and managed configuration, so inspect those sources if the shell result looks clean.\n\n```\nfor name in HTTPS_PROXY https_proxy HTTP_PROXY http_proxy \\  NO_PROXY no_proxy ALL_PROXY all_proxy ANTHROPIC_BASE_URL \\  NODE_EXTRA_CA_CERTS ANTHROPIC_API_KEY ANTHROPIC_AUTH_TOKENdo  if printenv \"$name\" >/dev/null; then    printf '%s is exported\\n' \"$name\"  fidone\n```\n\nPay attention when both cases of a proxy variable are present. A shell profile, an editor launcher, and WSL proxy propagation can each introduce a setting. Confirm which proxy the client is expected to use and whether the bypass list covers the intended host. If the proxy URL points to loopback, check where that service actually runs. A Linux process that calls its own loopback may fail to reach a service bound to Windows, depending on the WSL networking mode and service setup.\n\nCheck ANTHROPIC_BASE_URL against the route your team assigned. A leftover launcher can point WSL at a gateway that PowerShell never touches. A missing setting can do the reverse and send the Linux client toward the public service when it should use your employer’s gateway. If managed policy owns the setting, correct it with the owner and repeat the check in the original launcher. [Claude Code configuration scopes](https://code.claude.com/docs/en/settings)\n\nUse a fresh, empty folder you control for this test. Keep the configured provider, account, and model aligned where your deployment allows. The prompt has no repo data and asks Claude to return a single word. The deny rule removes tools from the model’s context for this run. Managed settings can still apply, so use a test environment your team already permits. A successful call can consume quota or incur API charges.\n\n```\nclaude -p --disallowedTools \"*\" -- \"Reply with exactly OK.\"\n```\n\nWrite down whether the command exits successfully and whether you see a model reply. Save the error category when it fails. Repeat with the same prompt in the working launcher. If print mode works in WSL but the interactive panel fails, run the same short prompt interactively in the affected surface. At that point you have a difference worth reporting at the editor or session layer. [Print mode and tool flags](https://code.claude.com/docs/en/cli-reference)\n\nIf the short prompt works but your regular session drops midway through an answer, collect the elapsed time and whether any tokens arrived. A failure before the first token gives the owner a different lead from a repeatable cutoff after output starts. Claude Code’s transport may encounter a problem that a brief HTTP probe never reaches. Compare the same modest, tool-free prompt that reliably exhibits the failure, with your team’s approval, and ask the proxy or gateway owner to match the timestamp with its logs. [Example issue report comparing successful and failed streams](https://github.com/anthropics/claude-code/issues/84194)\n\nSuppose both launchers target the same gateway, but WSL reports a trust error. Ask the endpoint team to confirm which issuer the client should see. Compare that with the trust bundle your WSL process actually uses. Once the approved bundle is provisioned, restart the affected launcher, capture Doctor again, and run the short model request. If the trust error becomes a 403, note that the request advanced to an HTTP responder and investigate that responder’s policy as a separate step.\n\nStart by comparing provider and auth method. For example, the Windows launcher may use a valid managed sign-in while WSL has a shell export from an old API setup. Check the selected account route before changing credentials. Once both launches use their intended method, rerun Doctor and the short request. Capturing the difference avoids confusing a refreshed credential with a change in route.\n\nCompare executable paths, current folder, version, and exported variable names from the two WSL terminals. Open a fresh terminal after any approved environment change, and restart the editor or its remote session if it owns the old process environment. If the same binary and config work in the standalone terminal, keep that reference in your ticket. It helps the editor owner reproduce the problem under the right parent process. [Anthropic’s installation and authentication troubleshooting](https://support.claude.com/en/articles/14552646-troubleshoot-claude-code-installation-and-authentication)\n\nIf the two shells launch different builds, first try the approved Linux install in the failing shell and verify the path again. Keep the network and account steady for that comparison. A clean pairing can save a network ticket when the actual fault is an alias that starts an older copy. If the builds match and Doctor still differs, the paired record gives you a better reason to investigate proxy or trust settings.\n\nIf Git and curl both work on the same WSL route, check which hosts they actually contacted. Git might use an internal server with a different trust chain. Curl might use a CA file configured for that tool alone. For a useful comparison, use the approved service hostname and test from the same shell. Keep the result narrow: “This client got an HTTP response from this route.” Then look at how Claude Code reached, or failed to reach, its own destination.\n\nIf your team runs the same CLI inside a dev container, collect a new baseline from within the container. The WSL host may have the right trust file while the image lacks it, or the container may get different proxy settings. Have the image owner provision the approved bundle through the normal build process. Verify a fresh container rather than relying on a change to a running instance that will disappear on the next rebuild.\n\nIf several people report the same error at once, compare their intended routes and check the provider’s incident page before proposing a local change. One common gateway may explain the shared symptom even when the public service is healthy. If the affected routes vary, give the responders two paired records from distinct launch environments. That helps them see whether there is a shared point of failure. [Claude status](https://status.claude.com/)\n\nInclude a timestamp, the failing launch surface, and the closest test that passes.\n\nOpen your ticket with one paired observation: “PowerShell completed the short model request. WSL in the remote editor returned an issuer error on the same approved network.” Add the time with its timezone, OS and WSL distribution, CLI versions, intended provider, and the sanitized error. Include any request ID the actual model request returned, if your support channel permits it. Ask the recipient one question they can answer, such as which CA bundle WSL should receive.\n\nIf the comparison only works after several things changed together, recreate the baseline in a safe test environment before you close the ticket. A repeatable fix should survive a fresh editor launch. Record the setting owner and where it is applied so the next developer can tell whether their shell, managed launcher, or distribution needs attention. The two commands you want to see succeed are Doctor in the original launch environment and the tiny model request through the intended route.\n\nYes. The CLI can report a stored sign-in while DNS, proxy authentication, or TLS trust fails on the current route. Compare claude auth status --text with Doctor and a short model request from the failing shell.\n\nCurl can use a different trust store, proxy behavior, or connection strategy. A bare curl request can also reach a different endpoint from the one configured in Claude Code. Use curl as an independent transport observation. Compare like-for-like hosts and preserve the CLI result as evidence for the real client.\n\nIt means a proxy is asking the client to authenticate. Confirm which proxy returned the response and which enterprise auth method it expects. Your Claude subscription or API credential serves a different part of the request.\n\nAutomatic proxy propagation supplies proxy information to WSL on supported systems. Manage Linux trust and the client’s CA configuration separately through your organization’s approved deployment. A new proxy setting can make a trust problem visible once traffic starts taking the expected path.\n\nRun it in both when their behavior differs. If you can take only one reading, use the exact environment that failed, including the same editor terminal if that is where you launched Claude Code. Record which binary the shell selected.\n\nA short probe tests reachability at that moment. To check streaming, reproduce the failure with a modest model prompt, record when output starts and stops, and compare the same request through the approved reference route. Give the resulting timestamp to whoever can inspect the gateway logs.\n\n[Claude Code Works in Windows but Fails in WSL](https://pub.towardsai.net/claude-code-works-in-windows-but-fails-in-wsl-b2c1572e26d0) was originally published in [Towards AI](https://pub.towardsai.net) on Medium, where people are continuing the conversation by highlighting and responding to this story.", "url": "https://wpnews.pro/news/claude-code-works-in-windows-but-fails-in-wsl", "canonical_source": "https://pub.towardsai.net/claude-code-works-in-windows-but-fails-in-wsl-b2c1572e26d0?source=rss----98111c9905da---4", "published_at": "2026-11-25 14:31:01+00:00", "updated_at": "2026-11-25 14:42:48.209559+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents"], "entities": ["Anthropic", "Claude Code", "Claude Code 2.1.331", "WSL", "PowerShell", "Microsoft", "VS Code"], "also_reported_by": [], "takeaway": "Run claude doctor, claude --version and claude auth status --text in both the failing WSL shell and a working PowerShell window before reinstalling, then compare launch environment, intermediary and destination in that order to isolate whether the failure is the Linux install, proxy, certificate cha", "recommendation": {"advice": "When Claude Code fails only in WSL, run claude doctor and claude auth status --text in both environments before reinstalling, and compare launch environment, proxy and destination in that order.", "playbook": "production-ops", "playbook_url": "https://wpnews.pro/playbooks/production-ops"}, "alternates": {"html": "https://wpnews.pro/news/claude-code-works-in-windows-but-fails-in-wsl", "markdown": "https://wpnews.pro/news/claude-code-works-in-windows-but-fails-in-wsl.md", "text": "https://wpnews.pro/news/claude-code-works-in-windows-but-fails-in-wsl.txt", "jsonld": "https://wpnews.pro/news/claude-code-works-in-windows-but-fails-in-wsl.jsonld"}}