← Back to CLI configuration guide

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:

text
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

  1. Press Win + R, type cmd and hit Enter to open the command prompt.
  2. Paste the following command and press Enter:
bash
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

  1. Open Terminal from your Applications list.
  2. Paste the following command and press Enter:
bash
jq '. + {"hasCompletedOnboarding": true}' ~/.claude.json > /tmp/tmp.json && mv /tmp/tmp.json ~/.claude.json
Tip: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.