ホーム 暮らし Complete Solutions for When Claude Code Isn't Working or Errors Occur | A Comprehensive Guide to 20 Common Patterns

Complete Solutions for When Claude Code Isn't Working or Errors Occur | A Comprehensive Guide to 20 Common Patterns

藤崎 健人 藤崎 健人 • 更新: • 公開: • 読了約 47 分
目次

Claude Code isn't working... You can definitely resolve that error.

n9213d1106d9b

"It won't start even though I installed it," "An error suddenly popped up and stopped my work," "It worked yesterday but not today despite doing the same thing." Whether you are a beginner or a regular user of Claude Code, encountering these types of troubles is unavoidable.

In this article, we categorize common errors and issues in Claude Code into 20 patterns and explain the causes and resolution steps in full. We have structured this so that if you arrived at this page by searching for an error message, you can jump to the relevant section by scrolling and resolve it immediately.

For installation procedures and initial setup of Claude Code, please also see How to Get Started with Claude Code | A Complete Guide from Installation to First Run.

Understanding Error Types in 5 Groups

Claude Code troubles can be broadly divided into the following 5 groups. First, confirm which group your error falls into, then proceed to the relevant section.

・Group A: Installation/Startup Errors (Patterns 1-5)
・Group B: Authentication/API Connection Errors (Patterns 6-9)
・Group C: Conversation/Execution Errors (Patterns 10-14)
・Group D: Output/Quality Issues (Patterns 15-18)
・Group E: Configuration/CLAUDE.md Related (Patterns 19-20)

Group A: Installation/Startup Errors (Patterns 1-5)

This group occurs frequently right after installation or when trying to start it after a long time. It is often caused by environment settings, and a characteristic is that once resolved, it is unlikely to recur.

Pattern 1 | "claude: command not found" is displayed

Symptom:When you type 'claude' in the terminal, 'command not found' is displayed.

Cause:Even if the installation is complete, the shell's PATH is usually not updated. If you installed globally via npm, it cannot start if the installation path is not included in the PATH.

Resolution Steps:
First, close the terminal completely and retry in a new window. If that does not resolve it, execute the following.

Run 'npm root -g' to check the npm global path. Check if the parent directory of the displayed path (e.g., /usr/local/bin if it is /usr/local/lib) is included in the PATH. If not, add 'export PATH="$PATH:/usr/local/bin"' to ~/.zshrc or ~/.bashrc and run 'source ~/.zshrc'.

Pattern 2 | Errors like "Node.js version too old" or "requires Node.js 18+"

Symptom:An error stating that the Node.js version is too old is displayed, and installation or startup fails.

Cause:Claude Code requires Node.js 18 or higher (20 or higher is recommended). This occurs when the Node.js installed on the system is old.

Resolution Steps:
Check the version with 'node -v'. If it is less than v18, update Node.js using nvm. Execute 'nvm install 20', 'nvm use 20', and 'nvm alias default 20' in order, then restart the terminal. If nvm is not installed, use 'brew install nvm' (Mac) or download the installer from the official Node.js website.

Pattern 3 | "npm install -g @anthropic-ai/claude-code" fails midway

Symptom:When executing the installation command, an error occurs midway and it terminates. This includes 'ENOENT', 'EACCES', 'network error', etc.

Cause:The main causes are file permission issues, network connection problems, or corrupted npm cache.

Resolution Steps:
First, clear the npm cache: run npm cache clean --force and try again. For permission errors (EACCES), run sudo npm install -g @anthropic-ai/claude-code or, as a fundamental solution, change the npm global directory to one under your home directory. For network errors, disable your VPN or try a different Wi-Fi connection.

Pattern 4 | Path issues on Windows - "'claude' is not recognized as an internal or external command..."

Symptoms:Attempting to launch it in the Windows Command Prompt or PowerShell results in a command not found error.

Cause:On Windows, the npm global installation path is sometimes not included in the system PATH by default. Additionally, script execution may be denied due to PowerShell execution policies.

Resolution Steps:
Run PowerShell as an administrator and check the global path with npm config get prefix. Add the displayed path (e.g., C:\Users\Username\AppData\Roaming\npm) to the system environment variable PATH. If you get a PowerShell script execution policy error, run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser. Installing on WSL (Windows Subsystem for Linux) often avoids these issues.

Pattern 5 | Installation succeeds, but it fails to launch every time

Symptoms:The version is displayed with claude -v, but running just claude does not launch it or it exits immediately.

Cause:This can be caused by corrupted configuration files or leftover old cache. There are also reports of security software blocking the execution.

Resolution Steps:
Delete the configuration files in the ~/.claude directory and restart. You can isolate the cause by temporarily disabling security software. If that does not solve it, uninstall using npm uninstall -g @anthropic-ai/claude-code and reinstall the latest version.

Group B: Authentication and API Connection Errors (Patterns 6-9)

Errors related to login and connection often occur during initial setup and when restarting after a long period of inactivity.

Pattern 6 | Cannot log in / Error on the authentication screen

Symptoms:When you launch claude and try to log in, the browser does not open, or it opens to an error page.

Cause:The authentication flow (OAuth) between the browser and Claude Code has been interrupted for some reason. This is often because the port is already in use or a firewall is blocking the local port.

Resolution Steps:
Close the terminal, restart it, and run claude again. If the browser does not open, copy the displayed URL and paste it directly into your browser. If it still fails, run claude logout to reset the session, then log in again with claude.

Pattern 7 | "Authentication failed", "Unauthorized", "401 error"

Symptoms:Even though login should be complete, "Authentication failed" or "401 Unauthorized" is displayed and the command cannot be executed.

Cause:This is often due to an expired authentication token or an issue with the account plan (e.g., an unrenewed subscription).

Resolution Steps:
Try claude logout followed by logging in again with claude. If that does not resolve it, access claude.ai in your browser to check your account status (subscription expiration, payment information). If you are setting the API key directly, verify that the ANTHROPIC_API_KEY environment variable contains the correct key.

Pattern 8 | "429 Too Many Requests" / "Rate limit exceeded"

Symptom:During use, an error such as "Too Many Requests" or "Rate limit" appears, and you are unable to use it for a while.

Cause:Claude Code has usage limits (rate limits). If you send a large number of requests in a short period, you will be temporarily blocked.

Solution:
Wait for a few minutes to 30 minutes and try again. If this happens frequently, it is effective to reduce the amount of context sent at once or break tasks into smaller pieces. Upgrading to the Max plan significantly increases the rate limit. How to choose a pricing plan is also covered in 5 Settings You Should Configure First in Claude Code.

Pattern 9 | Connection Timeout / "Network error" / "Connection refused"

Symptom:When you send a command, there is no response, and a timeout error is returned after a while.

Cause:This is a case of network connection issues, or a corporate proxy or firewall blocking access to the API.

Solution:
Check if you can access claude.ai in your browser. If you cannot, it is a network issue. If it happens on company Wi-Fi, you may need to configure corporate proxy settings. In many cases, this can be resolved by setting the proxy address in the HTTPS_PROXY environment variable. Also, check the Anthropic status page (status.anthropic.com) to see if there is a service outage.

Group C: Conversation and Execution Errors (Patterns 10-14)

These are errors that occur suddenly during work. They often involve file operations or command execution.

Pattern 10 | "Context length exceeded"

Symptom:After a long conversation, an error saying "Context window is full" or "Context length exceeded" appears.

Cause:There is a limit to the conversation history (context) that Claude Code can hold. If you continue working for a long time or across multiple files, you will reach the limit.

Solution:
Starting a new session (restarting claude) is the most reliable solution. When resuming work, recording "how far you have progressed" and "what to do next" in CLAUDE.md saves the trouble of explaining the context from scratch. You can also sometimes compress the context with the /compact command.

Pattern 11 | "File not found" / "No such file or directory"

Symptom:When you try to operate on a specific file, a "file not found" error appears.

Cause:In most cases, the directory where Claude Code is running and the path of the specified file are misaligned. This is likely to happen if you do not understand the "working directory" that serves as the starting point for relative paths.

Solution:
Check the current working directory with the pwd command and verify if the file you want to operate on is truly under that directory. Specifying the file path as an absolute path (/Users/username/Documents/filename.txt) is reliable. It is also effective to instruct it to check the contents of the directory with the ls command before performing operations.

Pattern 12 | "Permission denied" / Unable to read or write files

Symptom:When you try to edit, create, or delete a file, a "Permission denied" or "Access denied" error appears.

Cause:Claude Code is unable to operate due to the owner or permission settings of the target file or directory.

Resolution Steps:
Check file permissions with 'ls -la filename'. If you are the owner, grant permissions using 'chmod 644 filename' (for files) or 'chmod 755 directoryname' (for directories). If you are attempting to manipulate system files, sudo privileges are required, but please use sudo operations with Claude Code cautiously.

Pattern 13 | Bash tools or terminal commands cannot be executed from Claude Code

Symptoms:When asking Claude Code to execute a command, it says 'Bash tool not found' or 'Cannot execute'. Alternatively, it keeps prompting for permission.

Cause:Claude Code's default settings require confirmation for access to the file system or shell. This occurs when security settings are strict or permission settings in CLAUDE.md are insufficient.

Resolution Steps:
You can skip confirmation by launching with the '--dangerously-skip-permissions' option (use only in trusted work environments). Alternatively, explicitly stating 'Allow execution of ~ commands in this project' in CLAUDE.md will allow execution without repeated confirmation.

Pattern 14 | MCP server fails to start or cannot connect

Symptoms:You configured an MCP server, but connection fails. Errors like 'MCP server failed to start' appear.

Cause:This is caused by incorrect path settings for the MCP server, uninstalled dependency packages, or port conflicts.

Resolution Steps:
Check the path settings in '.mcp.json'. Ensure the command uses an absolute path and that necessary npm packages are installed. Launching with the '--mcp-debug' flag will display detailed MCP logs, making it easier to identify the cause of the error.

Group D: Output and Quality Issues (Patterns 15-18)

Cases where no error message appears, but there are issues with Claude Code's behavior or output.

Pattern 15 | Response cuts off or is incomplete

Symptoms:When generating long text or code, it stops abruptly. When asked to continue, it says 'I will continue from where I left off' but stops again.

Cause:This is caused by reaching the length limit (output token limit) for a single output. This is especially common with long code files or when creating documents spanning multiple sections.

Resolution Steps:
Break the task into smaller parts. For example, specifying 'Write one function at a time' or 'Write only section A, and tell me when you are done' is effective. Using the '/effort xhigh' command to increase the effort put into the output can also improve results.

Pattern 16 | Makes the same mistake repeatedly or instructions are not reflected

Symptoms:Even after saying 'Don't do X' multiple times, it repeats the same thing. It does not act as instructed.

Cause:The main cause is that the instructions are not written in CLAUDE.md or the prompt is ambiguous. Instructions given within a conversation are not carried over to the next session.

Resolution Steps:
The fundamental solution is to write instructions you want to repeat into CLAUDE.md. Explicitly state things like 'Never do ~' or 'In the case of ~, always output in the format of ~'. Also, make instructions specific and measurable (instead of 'write clearly', use 'write in 3 bullet points or less, each within 50 characters'). How to write CLAUDE.md is also explained in detail in 7 Pitfalls for Claude Code Beginners.

Pattern 17 | Japanese text is not displayed correctly or appears garbled

Symptom:Japanese input or output appears garbled, or the terminal displays "???" or symbols.

Cause:The primary cause is that the terminal's character encoding is not set to UTF-8.

Solution:
On Mac, set the "Encoding" to "Unicode (UTF-8)" in the terminal preferences. Run echo $LANG to verify if it displays ja_JP.UTF-8 or en_US.UTF-8. On Windows, running chcp 65001 in the command prompt will switch it to UTF-8.

Pattern 18 | Code does not execute or returns "Cannot execute"

Symptom:When asked to run code, it refuses, saying "I cannot execute this" or "I do not have the permission to do so."

Cause:This is because there is no access permission to the code execution tool (Bash), or code execution is restricted in the Claude Code settings.

Solution:
Explicitly instruct Claude Code to "Please execute using the Bash command." Also, by specifying the working directory when starting claude (claude --project /path/to/project), you can clarify the operation permissions within that directory. If it still does not execute, consider pasting the code into the terminal and running it manually.

Group E: Configuration and CLAUDE.md Related Errors (Patterns 19-20)

These are issues where configuration files do not work correctly or settings are not saved. This is a common type of error for those trying to master Claude Code.

Pattern 19 | CLAUDE.md is not being read or instructions are ignored

Symptom:Even though rules were written in CLAUDE.md, Claude Code appears to be ignoring them.

Cause:The most common case is that the CLAUDE.md file is in the wrong location (it is in a subdirectory instead of the project root). It also will not be read if the file name casing is incorrect (e.g., claude.md).

Solution:
CLAUDE.md must be placed in the directory where the claude command is executed (the project root). Use ls -la CLAUDE.md to verify that the file is in the correct location. Settings you want to apply globally can be written in ~/.claude/CLAUDE.md, which will be loaded for all projects.

Pattern 20 | Settings are not saved or are reset between sessions

Symptom:Settings conveyed during a conversation, such as "Please do X from now on," disappear in the next session.

Cause:Claude Code does not carry over conversation history between sessions. Instructions given within a conversation are limited to that specific session.

Solution:
Write all settings or instructions you want to persist into CLAUDE.md. By summarizing "things to do every time," "things that must never be done," "output format rules," and "frequently used project-specific information" in CLAUDE.md, you can maintain the same quality of work across sessions.

Frequently Asked Questions (FAQ)

Q. The error message is in English and I don't understand what it says

The most reliable method is to paste the error message directly into Claude Code and ask, "Explain the meaning of this error and how to fix it." Claude Code can explain its own errors and suggest solutions.

Q. I get scared and stop working every time an error occurs. How should I handle this?

Errors are valuable information that tell you a problem has occurred. Don't be afraid; share the error message directly with Claude Code and say, "Fix this error and continue the work." In many cases, Claude Code will think of a solution and fix it automatically.

Q. Why does it sometimes stop working suddenly the next day even though it was working today?

It can change due to external factors such as specification changes from updates, service maintenance, or rate limit reset timings. First, check the Anthropic status page, and if there are no issues, try updating to the latest version with claude update.

Q. What should I do if "this error doesn't fit any pattern"?

Copy the full error message and ask Claude Code directly. If that doesn't solve it, searching for similar cases in the official Anthropic documentation (docs.anthropic.com) or GitHub Issues is effective.

Summary: Identifying the "type" of error is the fastest shortcut to a solution

Claude Code errors can be broadly divided into five groups: "Installation/Startup," "Authentication/Connection," "Runtime," "Output Quality," and "Configuration." Just by looking at the error message and determining which group it belongs to, it becomes easier to guess the solution.

Also, if you are afraid of errors and stop working, the most efficient method is to "paste the error message directly into Claude Code and ask." Claude Code itself will analyze its own errors and provide a fix.

Initial settings and common pitfalls are also explained in detail in the following article. Please use it as a reference.

Related articles you may want to read:

Delivering the latest AI information in real-time

I share new features, usage techniques, and AI information that even non-engineers can use for Claude Code every day. If you follow @ai_hack_dx on X (formerly Twitter), you can receive breaking news before I write articles on note, as well as detailed tips that didn't fit into the articles, in real-time. Please follow me and let's connect.

同じカテゴリの記事

藤崎 健人

芸能取材歴10年のデスク。所属事務所の公式リリース、番組公式サイト、配信サービスの告知を一次情報として採用し、裏付けの取れない内容は記事にしていません。

おすすめの関連記事