Claude Code cannot connect to Anthropic services
Heads up:If you arrived here from the CLI configuration guide on a fresh setup, just run the snippet for your OS below, then return to the CLI guide and continue.
Symptoms
Right after npm-installing claude, running it from the terminal prints this error:
Unable to connect to Anthropic services Failed to connect to api.anthropic.com: ERR_BAD_REQUEST Please check your internet connection and network settings. Note: Claude Code might not be available in your country, check supported countries at https://anthropic.com/supported-countries
Or, on the first launch, the Welcome to Claude Code screen appears but never gets past the login-method selector. Both cases come from the onboarding flag missing in ~/.claude.json — the snippets below write it directly.
Windows
- Press Win + R, type cmd and hit Enter to open the command prompt.
- Paste the following command and press Enter:
powershell -Command "$f='%USERPROFILE%.claude.json';$j=Get-Content $f|ConvertFrom-Json;$j|Add-Member -NotePropertyName 'hasCompletedOnboarding' -NotePropertyValue $true -Force;$j|ConvertTo-Json|Set-Content $f"
Restart the Claude CLI — running claude should now drop you straight into the interactive prompt.
macOS
- Open Terminal from your Applications list.
- Paste the following command and press Enter:
jq '. + {"hasCompletedOnboarding": true}' ~/.claude.json > /tmp/tmp.json && mv /tmp/tmp.json ~/.claude.jsonTip:If the terminal reports jq not found, install it with
brew install jq first, then rerun the command above.Restart the Claude CLI — running claude should now drop you straight into the interactive prompt.
See also:← Back to CLI configuration guide