macOS Clash Client Permissions: Network Extensions and Keychain Prompts

Get Claude Code terminal requests working more reliably with a practical Clash Verge setup. Follow the profile import, proxy routing, and environment-variable checks, then use the troubleshooting tips to investigate timeouts and failed connections.

Understand the request path before changing settings

Claude Code runs in a terminal, but its network requests do not automatically follow the same proxy settings as a web browser. A browser may use the operating system proxy configured by Clash Verge, while a command-line process may connect directly unless its environment or runtime tells it to use a proxy. That difference can make Claude Code fail even when websites open normally in the browser.

For a typical proxied request, Claude Code reads proxy-related environment variables, sends the request to a local listening port on your computer, and Clash Verge passes it into the active mihomo core. The core then applies its routing mode, rules, and selected policy before connecting to the destination. A failure can occur at any of these steps: the local port may be wrong, the core may be stopped, a rule may select DIRECT, or the selected node may not reach the service.

Keep these layers separate while troubleshooting:

  • Clash Verge: manages the profile, core, system proxy, and optional TUN routing.
  • mihomo: listens for local proxy connections and applies the loaded configuration.
  • Terminal environment: supplies Claude Code with the local proxy address when the terminal process starts.
  • Routing policy: decides whether requests that reach mihomo use a proxy, go direct, or are rejected.

Menu labels vary between Clash Verge and Clash Verge Rev releases. Look for the profile or configuration page, the system proxy control, the core or service status, the port settings, and the connections or logs view. If a menu has moved in your version, use the setting’s description rather than relying on a path from an older screenshot.

Check the Clash Verge listener and routing mode

Open the active profile in Clash Verge and confirm that it has loaded successfully. Then check the core status and identify the local HTTP or mixed proxy port. A mixed port can accept both HTTP proxy requests and SOCKS connections; for Claude Code, use an HTTP proxy URL unless the version of Claude Code you use explicitly documents another supported proxy type. A port number such as 7890 is only an example. Use the value shown in your own settings.

Do not assume that enabling “System Proxy” configures every terminal program. That control usually updates the operating system’s proxy settings for applications that consult them; it does not necessarily create environment variables for shells or command-line processes. Conversely, setting variables in a terminal does not require the operating system proxy toggle to be enabled, provided the local Clash Verge listener is running and reachable.

CheckWhat to confirmWhy it matters
Active profileThe intended configuration is selected and loaded without a parse errorAn unloaded profile may leave no usable rules or proxy policies
Core statusThe mihomo core is runningA saved environment variable cannot connect if nothing is listening locally
HTTP or mixed portThe port matches the local listener shown in Clash VergeA stale or incorrect port usually produces a refused connection
Mode and policyRule mode is active and the relevant destination selects a working proxy policyA request can reach the core and still be routed directly or rejected
Connections and logsA test request appears with a destination and an expected policyThis distinguishes a terminal-to-core problem from a node or rule problem

For ordinary use, rule mode is usually the practical choice. It lets your profile route different destinations according to its rules. Switching the entire client to global mode is a broad diagnostic change, not a required Claude Code setting. If you use it briefly to compare behavior, note the original mode and restore it afterward.

When the client shows the request in its connections list, inspect the selected policy and whether it is a group or a concrete node. A policy group may have no usable selection, may point to a failed node, or may select a node that cannot reach the destination. Select a known-working option for a controlled test, then restore your preferred selection.

Set proxy variables in the terminal

Claude Code terminal requests commonly use the standard HTTP_PROXY and HTTPS_PROXY environment variables. Their values should be the local HTTP proxy address exposed by Clash Verge, not a remote node address. Substitute your actual port for PORT in the examples below. The examples use loopback, so the proxy is available only on the same computer.

Set both variables because an HTTPS destination is normally reached through an HTTP proxy using the CONNECT method. The scheme in the proxy URL describes the connection from the terminal to the local proxy; it does not mean that the destination website itself is HTTP. Do not use a socks5:// URL unless your Claude Code version and the specific proxy integration you use document SOCKS support.

macOS and Linux shells

In a zsh or bash terminal, set the variables in the current shell before launching Claude Code:

export HTTP_PROXY="http://127.0.0.1:PORT"
export HTTPS_PROXY="http://127.0.0.1:PORT"
claude

This change applies to the current shell and programs launched from it. Closing the terminal or opening a new shell will normally discard it. That makes a temporary test useful: it avoids changing the settings for unrelated applications. To keep the variables for future terminal sessions, add the two export lines to the startup file used by your shell, such as ~/.zshrc or ~/.bashrc, and open a new terminal afterward. Avoid placing credentials or sensitive tokens in a shared startup file.

Windows PowerShell

In PowerShell, set process-scoped variables in the same window where you will run Claude Code:

$env:HTTP_PROXY = "http://127.0.0.1:PORT"
$env:HTTPS_PROXY = "http://127.0.0.1:PORT"
claude

These values apply to that PowerShell process and its child processes. A separate PowerShell window, Windows Terminal tab, or IDE terminal may have a different environment. If you use Command Prompt instead, the corresponding temporary form is set HTTP_PROXY=http://127.0.0.1:PORT and set HTTPS_PROXY=http://127.0.0.1:PORT; run those commands and then start Claude Code in the same window.

For a terminal that is already open, changing a Windows user-level environment variable elsewhere may not update that process. Close and reopen the terminal after changing persistent settings. If Claude Code is launched from an IDE, fully restart the IDE if necessary so it inherits the new environment.

Avoid unnecessary proxy overrides

Start with HTTP_PROXY and HTTPS_PROXY. Some applications also inspect lowercase forms, but setting several competing variables can make diagnosis harder if they contain different values. If the documented variables do not appear to be read by your installed Claude Code version, check its current help or product documentation before adding extra settings.

NO_PROXY can exclude specific hosts from proxying, but an overly broad entry can bypass Clash for destinations you meant to send through it. For a clean test, remove an existing exclusion that covers the service being tested, or inspect it carefully. Do not set NO_PROXY=* if your intention is to proxy all requests.

Run a controlled terminal test

Make one change at a time so the result identifies a layer rather than simply showing that something changed. The following sequence tests the local listener first, then checks routing, and finally tests Claude Code itself.

  1. Record the baseline. Note the active profile, core status, local HTTP or mixed port, current mode, and selected proxy group. Save a copy of any configuration you plan to edit. Do not share a profile or log without removing subscription URLs, credentials, and node details.
  2. Confirm the port in Clash Verge. Check the actual listener value in the client. If the port changed after an update or profile import, update the terminal commands accordingly. Do not infer the port from a tutorial or from another computer.
  3. Set temporary variables. Use the shell example for your operating system, replacing PORT with the confirmed value. Keep the terminal open and launch the test from that same session.
  4. Test local connectivity. Use curl to request the service through the local proxy. A response from the remote service, including an HTTP error such as 404, can still show that the proxy connection completed; the aim here is to distinguish transport failure from an application-level response.
  5. Inspect the Clash Verge connection. While the request runs, open the connections view or core logs. Confirm that a connection arrived, note its destination, and check which policy handled it.
  6. Start Claude Code in the same shell. If the curl test works but Claude Code fails, keep the profile and route unchanged and investigate the Claude Code environment, authentication flow, or application-specific error next.
curl -I --proxy "http://127.0.0.1:PORT" https://api.anthropic.com

This command is a connectivity check, not a guarantee that an API call is authorized. A server response can confirm that the request reached an HTTPS endpoint through the proxy, while authentication or endpoint-specific requirements remain separate. If your curl build or shell does not support the shown option, check its local help and use the equivalent proxy option for that build.

In Clash Verge, compare what you see during this test with what you see when Claude Code runs. If curl appears in the connection list but Claude Code does not, the problem is likely between the terminal environment and Claude Code, or the two programs may be using different environments. If neither appears, first verify the local address, port, and core status. If both appear but one fails, compare the destination and policy rather than changing the listener at random.

Route Claude Code destinations through the intended policy

In rule mode, mihomo evaluates rules in order and applies the policy named by the first matching rule. The exact destination hosts involved can depend on the Claude Code version, sign-in method, and features being used. Requests for the API, account sign-in, and related services may not all use the same hostname. Treat the connection list and logs as the primary evidence for your current session instead of assuming one domain covers every operation.

If the connection list shows a Claude Code request going to DIRECT, inspect the active profile’s rules and policy names. A targeted rule may be appropriate if your profile supports custom rules, but it must come before any broader rule that would already match the same traffic. Use the exact policy name defined in your profile; names such as Proxy are examples, not universal built-in policies.

# Illustrative rule only: adapt the policy name and destination
# to the active profile and the host shown in Clash Verge.
rules:
  - DOMAIN,api.anthropic.com,Proxy
  - MATCH,Default

This is not a complete configuration. Do not paste it over an existing subscription profile: a valid profile must also define its proxy entries, groups, and other required settings. If the profile is generated or managed by a provider, use Clash Verge’s supported rule-override or merge mechanism rather than editing a temporary generated file that will be replaced at the next update.

A custom rule for api.anthropic.com will not automatically route every sign-in or account-related request. Check the destination shown by mihomo when authentication fails, and add or adjust rules only when the evidence points to a routing mismatch. Keep rules narrow and review their order; a broad domain or final-match rule can affect unrelated traffic.

When you change a rule or policy selection, reload the configuration if the client does not apply the change immediately, then repeat the same test. Confirm that the new connection uses the intended policy. If the policy is correct but the request still fails, test another known-working node and check whether the node can resolve and reach the destination. Do not assume that a different routing rule can repair a remote server outage or an unavailable node.

Troubleshoot timeouts and failed connections

Symptom or clueLikely layerNext check
ECONNREFUSED or connection refused to 127.0.0.1Local listenerConfirm the core is running and the proxy URL uses the current port
Timeout before a connection appears in Clash VergeTerminal environment or local connectionCheck the variable names, URL scheme, port, and terminal process
Connection appears with DIRECTRule or modeInspect rule order, active mode, and the selected policy
Connection uses a proxy but times outNode or remote routeTry a known-working policy and check the core log for the destination error
Browser sign-in works but CLI sign-in failsDifferent application environmentsCheck whether the terminal process has the proxy variables and whether its requests appear in the connection list
401 or 403 from the remote serviceAuthentication or service accessConfirm the account and authentication state; a proxy change alone may not resolve an access denial
Certificate or TLS verification errorSystem clock, TLS path, or inspectionCheck system time and the full error; do not disable certificate verification as a shortcut

When diagnosing a timeout, note whether it happens immediately or only after a long wait. An immediate refusal to a loopback address commonly points to a stopped core or incorrect port. A long wait after the connection appears in Clash Verge can point to an unreachable node, DNS issue, blocked destination, or remote timeout. The precise error and the connection record are more useful than the generic message “network error.”

If a terminal is running inside a container, virtual machine, remote SSH session, or Windows Subsystem for Linux, 127.0.0.1 refers to that environment—not necessarily the host running Clash Verge. A proxy listening on the host may therefore be unreachable from the isolated environment at that address. Check the network boundary and the host’s listening-address settings before attempting to use a different address. Do not enable LAN access broadly without understanding who can reach that listener and what authentication or firewall protections are in place.

For certificate errors, first check that the computer’s date and time are correct and compare the full error with the core logs. Avoid disabling TLS verification or installing an unknown certificate to “fix” a proxy connection. If an organization requires an approved inspection certificate, follow its documented configuration process and confirm that the certificate is trusted by the environment in which Claude Code runs.

After testing, remove temporary environment variables by closing the shell, or unset them in the current session. In zsh or bash, use unset HTTP_PROXY HTTPS_PROXY; in PowerShell, use Remove-Item Env:HTTP_PROXY and Remove-Item Env:HTTPS_PROXY. Restore any temporary mode, node, or profile changes. Keeping the final setup simple—one verified local listener, matching terminal variables, and a known routing policy—makes later failures much easier to isolate.

Download Clash