Troubleshooting
Solutions to the most common problems you will encounter with Claude Code. Organized by category. Start with the error message you are seeing and follow the steps.
Authentication Problems
"Not logged in" or "Authentication required"
Symptom: Claude Code says you need to log in, or immediately asks you to authenticate when you run claude.
Solution:
- Run
claude auth loginin your terminal - A browser window will open — complete the sign-in
- Return to your terminal; it should confirm you are logged in
- Try running
claudeagain
If the browser does not open automatically, Claude Code will print a URL. Copy and paste it into your browser manually.
"Authentication expired" or "Session invalid"
Symptom: Claude Code was working before but now says your session has expired.
Solution:
- Run
claude auth logoutto clear the old session - Run
claude auth loginto sign in again - Check your account status at claude.ai — make sure your subscription is active
"API key not found" or "ANTHROPIC_API_KEY not set"
Symptom: You are trying to use Claude Code with a direct API key instead of a Claude.ai account, and it cannot find the key.
Solution:
- Set the environment variable in your terminal:
export ANTHROPIC_API_KEY=your-key-here - To make this permanent, add that line to your
~/.zshrcor~/.bashrcfile - After editing the file, run
source ~/.zshrc(or restart your terminal)
Installation Problems
"claude: command not found"
Symptom: You type claude and the terminal says the command does not exist.
Solution:
First, check if Claude Code is installed:
which claude
ls ~/.claude/bin/If it is not installed, install it:
curl -fsSL https://claude.ai/install.sh | bashIf it is installed but the command is not found, the installation directory might not be in your PATH. Add it:
echo 'export PATH="$HOME/.claude/bin:$PATH"' >> ~/.zshrc
source ~/.zshrcRestart your terminal after making PATH changes.
Claude Code installs but immediately crashes
Symptom: Running claude causes an error before anything happens, or it exits immediately.
Solution:
- Check if Node.js is installed and up to date:
node --version(needs version 18 or higher) - Try updating Claude Code:
claude update - Try a clean reinstall: uninstall with the uninstall script, then reinstall with the install script
- Check the error message — it often tells you exactly what is wrong
"Permission denied" during installation
Symptom: The install script fails with a permission error.
Solution: Do NOT use sudo with the Claude Code install script. The native installer is designed to install to your home directory, which does not require administrator privileges.
If you see permission errors, check:
- Do you have write access to
~/.claude/? - Is your home directory on a read-only filesystem?
- Try:
mkdir -p ~/.claude && chmod u+w ~/.claude
Runtime Errors
"Rate limit exceeded"
Symptom: Claude Code stops mid-task with a message about rate limits or "too many requests."
What it means: You have sent too many requests in a short period. This is a limit imposed by Anthropic's API to prevent abuse.
Solution:
- Wait a few minutes and try again
- For long automated tasks, consider adding pauses between requests
- If you hit rate limits regularly, check your usage at console.anthropic.com (if using API key billing)
- Claude.ai subscription users have usage limits that reset on a billing cycle — check your usage dashboard
"Context length exceeded" or "Conversation too long"
Symptom: Claude Code says the conversation is too long, or responses become truncated or low quality after a very long session.
What it means: The conversation has exceeded Claude's context window — it can no longer hold the entire history of what was said.
Solution:
- Run
/compactto compress the conversation history. Claude will summarize earlier parts while keeping recent context. - For a fresh start: run
/clearto start a new conversation (you will need to re-establish context) - For large codebases: focus each session on one task rather than trying to do everything in one long conversation
- Avoid pasting large files repeatedly — reference them with
@filenameinstead
"Tool execution failed" or "Command failed"
Symptom: Claude Code tried to run a command and it failed.
Solution:
- Read the error message — it usually tells you exactly what failed
- Ask Claude: "Why did that command fail? Can you try a different approach?"
- Run the command yourself (use
!prefix) to see the full error output - Check that required tools are installed:
which npm,which python, etc.
"File not found" or "No such file or directory"
Symptom: Claude Code cannot find a file it is trying to read or edit.
Solution:
- Make sure you are in the right directory (
pwdto check) - Check if the file name or path is spelled correctly
- Ask Claude: "What directory are you looking in? What files exist here?"
- Run
lsorfind . -name "filename"to locate the file
Permission Problems
"Permission denied" when editing a file
Symptom: Claude Code tries to edit a file and gets a permission denied error from the operating system.
Solution:
- Check file permissions:
ls -la filename - Make the file writable:
chmod u+w filename - If the file is owned by root or another user, you may need
sudo— but be careful usingsudowith Claude Code
"Denied by permission rules" — Claude refuses to do something
Symptom: Claude Code tells you it is not allowed to perform a specific action because of your settings.
Solution:
- Run
/permissionsto view the current allow/deny rules - Find the deny rule that is blocking the action
- Either remove the deny rule, or add a more specific allow rule
- Check both your user settings (
~/.claude/settings.json) and project settings (.claude/settings.json)
Claude keeps asking permission for the same command repeatedly
Symptom: You have approved npm run test before but Claude asks again in the next session.
Solution: Add the command to your allowlist so it is always approved:
In .claude/settings.json:
{
"permissions": {
"allow": ["Bash(npm run test)"]
}
}Or when Claude asks for permission, look for a "don't ask again" option.
VS Code Extension Problems
The Claude Code extension is not visible
Symptom: You installed the extension but cannot find the spark icon.
Solution:
- Make sure you have a file open in the editor — the toolbar icon only appears with a file open
- Check VS Code version: requires 1.98.0 or higher (Help → About)
- Restart VS Code: Command Palette → "Developer: Reload Window"
- Try disabling other AI extensions (Cline, Continue, GitHub Copilot) temporarily — they can sometimes conflict
- The Status Bar icon (bottom right: "✱ Claude Code") is always visible even without a file open
Claude Code extension never responds to prompts
Symptom: You type a prompt and nothing happens.
Solution:
- Check your internet connection
- Start a new conversation to rule out a stale session
- Try running
claudein VS Code's integrated terminal — more detailed errors appear there - Reinstall the extension: uninstall via Extensions panel, reload VS Code, reinstall
Git and GitHub Problems
"gh: command not found" when trying to create a pull request
Symptom: Claude Code cannot create a pull request because the gh CLI is not installed.
Solution:
- Install the GitHub CLI: https://cli.github.com/
- Mac:
brew install gh - After installing, authenticate:
gh auth login - Try the pull request command again
"Remote origin not found" or "No remote configured"
Symptom: Claude Code cannot push to GitHub because there is no remote repository configured.
Solution:
- Create a new repository on github.com first
- Then add the remote:
git remote add origin https://github.com/username/repo-name.git - Or ask Claude: "Help me connect this project to a new GitHub repository"
Git says "nothing to commit"
Symptom: You ask Claude to commit but git says there is nothing to commit.
What it means: All your files are either already committed or excluded by .gitignore.
Solution:
- Run
git statusto see what git sees - If you have new files that git is not tracking, run
git add .to stage them - Ask Claude: "What is the current git status? Why does it say nothing to commit?"
CLAUDE.md Problems
Claude is not following instructions in CLAUDE.md
Symptom: You have instructions in CLAUDE.md but Claude seems to be ignoring them.
Solution:
- Run
/memoryto verify the CLAUDE.md file is actually being loaded — it will be listed there if it is - Make sure the file is in the right location: either
./CLAUDE.mdor./.claude/CLAUDE.md - Make instructions more specific: "Use 2-space indentation" works better than "write clean code"
- Keep the file under 200 lines — longer files have lower adherence
- Check for contradictions: two rules saying different things may cancel each other out
CLAUDE.md changes are not being picked up
Symptom: You edited CLAUDE.md but Claude seems to be using the old version.
Solution:
- Start a new Claude Code session — CLAUDE.md is read at the start of each session
- Run
/memoryto confirm which version is loaded - Make sure you saved the file before starting the session
Performance and Slow Responses
Claude Code is responding very slowly
Symptom: Responses take 30 seconds or more; it feels sluggish.
Possible causes and solutions:
- High demand: Anthropic's servers may be under high load. Wait a few minutes and try again.
- Very long conversation: Use
/compactto compress history. Long conversations slow things down. - Large files in context: Avoid having Claude hold very large files in memory unnecessarily.
- Network issues: Check your internet connection. Try
ping claude.ai.
Claude Code seems to "forget" things mid-session
Symptom: Claude stops referencing context it knew earlier in the same conversation.
What it means: The conversation may have been compacted automatically (Claude summarized older messages to free up context space).
Solution:
- Remind Claude of key context: "Earlier in this session you were working on X. Here's a quick summary of where we are..."
- Keep important facts in CLAUDE.md so they survive compaction
- Use
/compactmanually before starting a new major task to compact on your terms
Getting More Help
If none of the above solves your problem:
Ask Claude directly: "I'm having trouble with [description]. What should I try?" Claude has access to its own documentation and can help troubleshoot itself.
Check the official docs: https://code.claude.com/docs
File an issue: For bugs, the GitHub repository at https://github.com/anthropics/claude-code accepts issues with detailed bug reports.
Community: The developer community around Claude Code shares tips and solutions in online forums and Discord servers — search for "Claude Code community."
Found a problem not listed here? The debugging mindset from Chapter 12 applies: describe the symptom precisely, note what you have already tried, and use Claude itself to help diagnose the issue.