Last updated 13 October 2026
Fix tool execution denied in Claude Code
Identify the cause of tool execution denied errors
You encounter the tool execution denied error when Claude Code tries to launch a local script or binary that your system blocks for security reasons. This failure typically happens at the shell level before Claude can even begin the task. It is a common frustration when setting up new Model Context Protocol tools or running custom automation scripts. The error usually manifests as a permission denied message or an exit code 126 in your terminal output. Because Claude Code acts as a bridge between the AI model and your local filesystem, it must follow the same security rules as any other process running in your terminal emulator.
To fix this, you must determine which layer of your operating system is blocking the command. It could be a simple file permission issue, a shell path conflict, or a more aggressive security feature like macOS Gatekeeper or Windows Execution Policy. If you try to run the command manually in your terminal and it fails with the same error, the problem lies with your system configuration. If the command works manually but fails when Claude calls it, the issue likely relates to the environment variables or the configuration file that Claude uses to find and execute your tools. Identifying the specific error code is your first step toward a resolution.
Check and fix file permissions on Unix systems
If you are on macOS or Linux, your first check should be the execution bits of the file. Navigate to the directory where the tool is located and run the ls -la command. Look at the string of letters on the far left of the output. For a tool to run, it must have an x in the permission string, which stands for executable. A standard executable file often shows rwxr-xr-x. If you only see r and w, the operating system will prevent any process, including Claude Code, from running that file as a program. This is a safety measure to prevent data files from being executed as code.
You can grant the necessary permissions by using the chmod command. Type chmod +x followed by the name of the script or binary. If the file is owned by a different user or is located in a protected system directory, you may need to prefix the command with sudo. Once you have applied this change, run the ls -la command again to verify that the x bit is now present. Try running the tool directly from your shell to confirm it launches. If it works for you, it should now work for Claude Code as well, provided the path to the file is correct in your configuration.
Configure the Claude desktop settings file correctly
Claude Code often pulls tool definitions from the same configuration file used by the Claude desktop application. On macOS, this file is located at ~/Library/Application Support/Claude/claude_desktop_config.json. On Windows, you can find it at %APPDATA%\Claude\claude_desktop_config.json. Open this file in your preferred text editor to inspect the mcpServers object. Every tool you want to use must be defined here with a clear command and any required arguments. A common mistake is using a relative path for the command, which causes the execution to fail because Claude cannot resolve where the file lives relative to its own process.
Always use absolute paths in your configuration file to avoid ambiguity. For example, instead of writing script.sh, write the full path like /Users/username/scripts/script.sh. If your tool requires a specific runtime like Node.js or Python, ensure the path points to the correct executable for that language. You should also check the JSON syntax for any missing commas or brackets, as a malformed config file will prevent Claude from loading any tools at all. After making changes to this file, you must restart your Claude Code session for the new settings to take effect and for the permissions to be re-evaluated.
Clear macOS Gatekeeper and quarantine flags
macOS uses a security feature called Gatekeeper to prevent the execution of unsigned or unverified software. When you download a tool or a script from the internet, the OS attaches a quarantine attribute to it. If Claude Code tries to run a quarantined file, the system will block the execution and return a permission error. You can check if a file is quarantined by running the xattr command followed by the filename. If you see com.apple.quarantine in the output, you must remove it before the tool can run without manual intervention. Use the command xattr -d com.apple.quarantine followed by the filename to clear the flag.
Beyond individual file flags, you must ensure your terminal application has the necessary permissions to access your files. Open your System Settings and navigate to the Privacy and Security section. Find the Full Disk Access menu and ensure that your terminal app, whether it is the default Terminal, iTerm2, or the integrated terminal in VS Code, is toggled to the on position. Without this permission, the terminal cannot grant Claude Code the rights it needs to execute scripts in protected areas of your disk. This is a common requirement for developers working on macOS Sequoia or Sonoma, where security defaults are more restrictive.
Adjust Windows PowerShell execution policies
Windows users frequently face execution denied errors because of the PowerShell Execution Policy. This security feature determines which types of PowerShell scripts can be loaded and run on your system. By default, Windows often sets this to Restricted, which prevents all scripts from running. To check your current policy, open a PowerShell window and type Get-ExecutionPolicy. If the output is Restricted or AllSigned, Claude Code will fail to run any .ps1 scripts or many Node.js based CLI tools that use shell wrappers. This block results in the tool execution denied error regardless of your user account permissions.
To fix this, you should set the policy to RemoteSigned. This allows you to run scripts you create locally while still requiring a digital signature for scripts downloaded from the internet. Run the command Set-ExecutionPolicy RemoteSigned -Scope CurrentUser in your PowerShell window. You do not always need administrative privileges to change the policy for the current user, making this a safe and effective fix for most development environments. Once this policy is updated, Claude Code will be able to launch the necessary shell scripts to power its tools and automate your tasks on Windows.
Monitor concurrent tool usage with adhdTerminal
Managing these permissions across multiple projects can get confusing if you have many terminal windows open. If you have several Claude Code sessions running at the same time, you might miss the one that is stuck waiting for a password or a security confirmation. This is where adhdTerminal becomes the honest answer for managing multiple agents. adhdTerminal is a native app for macOS and Windows, made by MINDBALANCER OU in Estonia, not affiliated with Anthropic. It runs many Claude Code sessions side by side, each one a tile on a wall. A tile has a colour, a number and a name, and shows whether it is working, waiting for you, done or idle.
This visual feedback tells you exactly which session needs a permission fix without you having to hunt through tabs. When a tool execution is denied in one session, the tile status will change to show it is waiting for your input. You can quickly switch to that specific terminal environment, fix the permission error using the methods described above, and then tell Claude to retry the task. Because each tile shows the last exchanges of its conversation, you can see the specific error message and the file path involved without even clicking into the session. This makes it much easier to debug permission issues when you are working on several features at once.
Verify environment variables and path settings
Environment variables are a frequent source of hidden execution failures. Many CLI tools depend on specific variables like PATH, API-KEY, or HOME to function. When Claude Code launches a tool, it might do so in a clean environment that does not include all the variables you have set in your interactive shell profile. If a tool fails because it cannot find a dependent library or a configuration file, the shell might report this as a generic execution denial. You can verify what Claude sees by asking it to run a simple command like printenv or echo $PATH to see if your expected directories are included.
If variables are missing, you can define them directly in the environment section of your Claude configuration file. This ensures that every time Claude calls a tool, it passes the correct context to the subprocess. Alternatively, make sure your shell profile files like .zshrc or .bash_profile are correctly exporting these variables so they are available to any subshells created by Claude. After updating your profile, you must restart your terminal or run the source command on the profile file to apply the changes. This step ensures that the tool has all the permissions and data it needs to execute its logic successfully.
Identify path shadowing and version conflicts
Path shadowing occurs when you have multiple versions of a tool installed and the system picks the wrong one. For example, macOS comes with a system version of Python that is often restricted, while you might have a different version installed via Homebrew. If Claude Code attempts to run the system version instead of your local version, it may hit a permission wall. Use the which command on macOS or the where command on Windows to see the absolute path of the binary that the shell resolves. If the path points to a system directory like /usr/bin instead of a user-controlled directory, you have a shadowing problem.
You can resolve this by adjusting your PATH variable so that your preferred tool directories appear earlier in the list. This ensures that the shell finds your authorized and configured binaries first. In your configuration file, you can also bypass path resolution entirely by providing the full absolute path to the specific binary you want Claude to use. This is the most reliable way to ensure that Claude Code is not accidentally trying to execute a protected system file or a version of a tool that lacks the necessary permissions for your project files.
Debug with system logs and state monitoring
If you have checked permissions and paths but the error persists, you should look at the system logs for more detail. On macOS, the Console app provides a real-time view of system errors. Search for the name of the tool or the word denied to find logs from the kernel or the security subsystem. On Windows, the Event Viewer tracks security audits and blocked process attempts under the Windows Logs section. These logs often provide the specific reason for the denial, such as a violation of a sandbox policy or a conflict with an antivirus program that you might not have noticed otherwise.
If you are using adhdTerminal to run many sessions side by side, you can monitor the state of these long running tasks easily. adhdTerminal is useful here because its tiles reopen in the same place after a restart and resume the same session. A free iPhone app mirrors the wall over an end to end encrypted link and can answer a prompt or send the next task. This means if you fix a permission issue and start a long tool execution, you can walk away from your desk and see the progress on your phone. If another permission prompt appears, you will see the tile status change to waiting for you, allowing you to handle the issue as soon as you return to your computer.
Questions people ask
Can I run Claude Code as root to avoid permission errors?
You should not run Claude Code or its tools with sudo or as a root user. This creates a significant security risk because it gives the AI agent full control over your entire system. Instead, fix the specific file permissions or add your user to the necessary groups to grant access to the tools you need.
Why does my tool work in a normal terminal but fail in Claude Code?
This usually happens because Claude Code uses a different shell environment or path than your interactive terminal session. Claude might not load your full shell profile, so it misses custom PATH entries or environment variables. You can fix this by providing absolute paths to your tools in the configuration file or by explicitly setting the environment variables in the Claude config JSON.
How can I tell if a tool is blocked by my antivirus instead of the OS?
Check your antivirus quarantine or history logs for any entries related to your terminal or the specific tool binary you are trying to run. Most security software will generate a notification or a log entry when it blocks an execution attempt. If you find a block, you can add a specific exclusion for that path or file to allow Claude to use it.
Read next
- Access git submodules in Claude CodeFix issues where Claude Code cannot see or modify code located inside nested git submodules within your main repository.
- Allow Claude Code to run shell scriptsResolve tool execution errors by adjusting permission settings to let Claude Code execute local bash or powershell scripts in your terminal.
- Break a linter error loop in ClaudeWhat to do when Claude Code fixes one linting error only to create another, leading to a circular set of edits.
- Change the Node version for Claude CodeResolve compatibility issues by switching the Node.js version used by Claude Code without breaking your other local development tools.