Skip to main content

Network and Proxy

These variables control how Claude Code reaches the network. They set the API base URL, proxies, custom certificates, timeouts, and retry counts. Use them behind a company proxy or when you route traffic through a gateway.

This page lists 68 variables. HTTPS_PROXY, NO_PROXY, and ANTHROPIC_BASE_URL are the usual ones. Project settings cannot set some endpoint variables before you trust the folder.

Example​

export HTTPS_PROXY="http://proxy.example:8080"
export NO_PROXY="localhost,127.0.0.1"
export API_TIMEOUT_MS=1200000
claude

API calls go through the proxy and wait up to 20 minutes.

Variables​

The table is sorted by name. See Environment Variables for what each column and badge means.

VariableStatusWhat it doesValues and defaultNotes
all_proxy
Undocumented: Only the program shows this item. It can change without notice.
Lower case proxy variable. It is the last fallback after HTTPS_PROXY and ALL_PROXY for git proxy settings.Text. Non-empty string. Also listed with proxy namesAll sessions
ANTHROPIC_BASE_URL
Documented: An official docs page names this item.
Overrides the API endpoint. A non-first-party host changes first-party checks, such as Remote Control. Since 2.1.304 tool search stays on behind a custom URL, and a 400 or 422 from the gateway is retried without it.Text. An unset value or an Anthropic host counts as first partyAll sessions. Not set from project env before trust
ANTHROPIC_CUSTOM_HEADERS
Documented: An official docs page names this item.
Adds custom request headers.Text. Split on new lines, each Name: Value at the first colon. Claude Code drops bad header names or values with a warningAll sessions. Not set from project env before trust
ANTHROPIC_UNIX_SOCKET
Documented: An official docs page names this item.
Sends first-party API requests over this Unix socket path.Text. Claude Code passes it as the unix fetch option. Also in the host-managed provider list with CLAUDE_CODE_PROVIDER_MANAGED_BY_HOSTFirst-party API client, all. Not set from project env before trust
API_FORCE_IDLE_TIMEOUT
Documented: An official docs page names this item.
Forces the streaming body idle timeout on or off.A number. A true value forces it on and a false value (0) turns the fetch timeout offAnthropic API client, all. Not set from project env before trust
API_TIMEOUT_MS
Documented: An official docs page names this item.
Sets the API request timeout in milliseconds.A number of milliseconds, 600000 (10 minutes) by default. Whole number. Errors show a hint to raise itAll sessions. Not set from project env before trust
CARGO_HTTP_CAINFO
Undocumented: Only the program shows this item. It can change without notice.
Names the CA bundle file for Cargo. Claude Code sets it to the sandbox CA bundle for sandboxed commands, next to SSL_CERT_FILE and others.Text. Also in a list of CA env namesSandboxed commands and remote sessions
CLAUDE_AGENT_SDK_CLIENT_APP
Documented: An official docs page names this item.
Names the client app of an Agent SDK host. Claude Code adds it to the user agent as client-app/<value>.TextSDK hosts. Not set from project env before trust
CLAUDE_AGENT_SDK_VERSION
Undocumented: Only the program shows this item. It can change without notice.
Reports the Agent SDK version. Claude Code adds it to the user agent as agent-sdk/<value>.Text. The SDK host sets itSDK hosts. Not set from project env before trust
CLAUDE_BG_GATEWAY_WITHHELD
Undocumented: Only the program shows this item. It can change without notice.
Names a gateway setting that the dispatcher did not pass to a background session. The session then prints a no-gateway hint.Text. Active only when ANTHROPIC_BASE_URL is unset. Claude Code removes it from the child envBackground sessions. Not set from project env before trust
CLAUDE_BYTE_STREAM_IDLE_TIMEOUT_MS
Documented: An official docs page names this item.
Sets the idle timeout of the byte-level streaming watchdog.A number of milliseconds. Whole number of 1 or more, clamped to 10000-1800000. Else a first-party default of 180000 from a feature flagAPI streaming. Not set from project env before trust
CLAUDE_CODE_ADDITIONAL_PROTECTION
Undocumented: Only the program shows this item. It can change without notice.
Adds the x-anthropic-additional-protection: true header to API requests.On or off. Read when Claude Code builds the API clientAPI requests. Not set from project env before trust
CLAUDE_CODE_API_BASE_URL
Undocumented: Only the program shows this item. It can change without notice.
Gives a fallback API base URL. The Files API uses it when ANTHROPIC_BASE_URL is unset. Default https://api.anthropic.com.Text. ANTHROPIC_BASE_URL wins when both are set. Credential checks also treat it as a base URL sourceFirst-party API and Files API. Not set from project env before trust
CLAUDE_CODE_ATTRIBUTION_HEADER
Documented: An official docs page names this item.
Controls the attribution block at the start of the system prompt. A falsy value such as 0 omits it.Text. Policy settings have a rule for it. Repo-committed settings may not re-point itFirst-party API, not CLAUDE_CODE_REMOTE
CLAUDE_CODE_CERT_STORE
Documented: An official docs page names this item.
Chooses the CA certificate sources for TLS.A comma-separated list, bundled,system by defaultAll sessions
CLAUDE_CODE_CLIENT_CERT
Documented: An official docs page names this item.
Gives the path of the client certificate file for mTLS.Text. Claude Code reads the file and skips a cert and key that do not matchAll sessions
CLAUDE_CODE_CLIENT_KEY
Documented: An official docs page names this item.
Gives the path of the client private key file for mTLS.Text. Claude Code reads the fileAll sessions
CLAUDE_CODE_CLIENT_KEY_PASSPHRASE
Documented: An official docs page names this item.
Gives the passphrase of an encrypted client key.Text. Claude Code uses it for the key check and the TLS agentAll sessions
CLAUDE_CODE_DISABLE_MTLS_RELOAD_ON_STALE_CONNECTION
Documented: An official docs page names this item.
Stops the re-read of the mTLS client cert and key after a connection-level API error.On or off. Only matters when CLAUDE_CODE_CLIENT_CERT is setMTLS setups
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC
Documented: An official docs page names this item.
Turns off nonessential network traffic such as updates, telemetry and error reporting.On or offAll sessions
CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK
Documented: An official docs page names this item.
Stops the non-streaming retry after a stream fails mid-stream.On or offAll sessions. Project env can set it before trust
CLAUDE_CODE_ENABLE_FINE_GRAINED_TOOL_STREAMING
Documented: An official docs page names this item.
Gated: Works only behind a flag or a server gate. A feature flag or server gate decides by default. This variable overrides it
Forces tool input streaming on or off. Code matches the docs.On, off, or unset. 0 is off. Else first party needs a feature flag, Vertex and Bedrock need model support and no custom base URL, 1 forces on. Since 2.1.309 a Bedrock base URL on Amazon's own https://bedrock-runtime.<region>.amazonaws.com host does not count as customAll sessions. Project env can set it before trust
CLAUDE_CODE_EXTRA_BODY
Documented: An official docs page names this item.
Merges a JSON object into the top level of every API request body.JSON text. Ignored when org policy blocks experimental betas. Passed on to background sessionsAll sessions
CLAUDE_CODE_EXTRA_METADATA
Undocumented: Only the program shows this item. It can change without notice.
Merges a JSON object into the metadata of API requests.JSON text. Claude Code logs an error and ignores a bad valueAll sessions
CLAUDE_CODE_GATEWAY_HINT_HEADERS
Documented: An official docs page names this item.
Gated: Works only behind a flag or a server gate. Works only behind a feature flag or server gate
Sends or stops the gateway hint headers such as x-claude-code-request-class.On, off, or unset. Unset sends them on some connections and else uses a feature flag on first partyAll sessions
CLAUDE_CODE_GATEWAY_MODEL_DISCOVERY_TIMEOUT_MS
Documented: An official docs page names this item.
Sets the timeout of the gateway /v1/models discovery request.A number of milliseconds, 3000 by default. Whole number from 1 to 2147483647, plain digitsGateway setups with discovery on
CLAUDE_CODE_GZIP_CCR_REQUEST_BODIES
Undocumented: Only the program shows this item. It can change without notice.
Turns gzip of CCR worker request bodies on or off.On, off, or unset. Used only for the ccr_worker sourceRemote worker sessions
CLAUDE_CODE_GZIP_DATADOG_LOGS
Undocumented: Only the program shows this item. It can change without notice.
Turns gzip of Datadog log batches on or off.On, off, or unset. Unset is on only in Anthropic-hosted remote sessions (CLAUDE_CODE_REMOTE set, CLAUDE_CODE_ENVIRONMENT_KIND unset, so not BYOC), else off. If Datadog refuses a gzipped batch, gzip is off for the rest of the processAll sessions
CLAUDE_CODE_GZIP_REQUEST_BODIES
Documented: An official docs page names this item.
Turns gzip of request bodies to Anthropic on or off. Set 0 for a TLS-inspecting proxy.On, off, or unset. Compression is skipped for a proxy, mTLS, a custom CA, or a Unix socket. Level comes from CLAUDE_CODE_GZIP_REQUEST_BODY_LEVELDirect Anthropic connections
CLAUDE_CODE_GZIP_REQUEST_BODY_BLOCKS
Undocumented: Only the program shows this item. It can change without notice.
Gated: Works only behind a flag or a server gate. Works only behind a feature flag or server gate
Sets the blocks gzip mode for large request bodies, from 524288 chars up.A number, 0 by default. Whole number from 0 to 2, plain digits. Only 1 and 2 actMessages API requests
CLAUDE_CODE_GZIP_REQUEST_BODY_LEVEL
Undocumented: Only the program shows this item. It can change without notice.
Gated: Works only behind a flag or a server gate. Works only behind a feature flag or server gate
Sets the gzip level for request bodies.A number, 0 by default. Whole number from 0 to 9, plain digits. Only 1 to 9 actAll API requests
CLAUDE_CODE_HTTP_PROXY
Undocumented: Only the program shows this item. It can change without notice.
Gives the fallback HTTP proxy. Claude Code uses it to build the proxy variables of child tools when HTTP_PROXY and http_proxy are empty.Text. Fills YARN_*, npm_config_*, and GLOBAL_AGENT_* proxy vars that are unsetAll sessions, child process env
CLAUDE_CODE_HTTPS_PROXY
Undocumented: Only the program shows this item. It can change without notice.
Gives the fallback HTTPS proxy. Claude Code uses it to build the proxy variables of child tools when HTTPS_PROXY and https_proxy are empty.Text. Fills YARN_*, npm_config_*, and GLOBAL_AGENT_* proxy vars that are unsetAll sessions, child process env
CLAUDE_CODE_INCREMENTAL_REQUEST_BODY
Undocumented: Only the program shows this item. It can change without notice.
Gated: Works only behind a flag or a server gate. Works only behind a feature flag or server gate
Builds API request bodies step by step, from the body of an earlier request. Added in 2.1.311.A number, 0 by default. Needs the first-party provider and the feature flag tengu_soft_kurzweil. A request with output_format set is not built this way. A body that fails a check is not usedFirst-party API requests
CLAUDE_CODE_MAX_RETRIES
Documented: An official docs page names this item.
Sets how many times Claude Code retries a failed API request.A number. Whole number, 0 or more. Claude Code clamps a value above the cap with a warning unless the retry watchdog is onAll sessions
CLAUDE_CODE_NONSTREAMING_TIMEOUT_RETRIES
Documented: An official docs page names this item.
Limits the re-sends of a non-streaming request that reaches its timeout. 0 fails on the first timeout.A number. Whole number min 0, digits only. Unset uses a built-in count only when the retry watchdog is onAll sessions
CLAUDE_CODE_OVERLOADED_RETRY_BASE_DELAY_MS
Documented: An official docs page names this item.
Sets the first delay of the exponential backoff for retries of an overloaded API error.A number of milliseconds. Whole number from 500 to 32000 in plain digits, else unset. Used only on the overloaded branch of the retry loopAll API requests
CLAUDE_CODE_OVERLOADED_RETRY_MAX_DELAY_MS
Documented: An official docs page names this item.
Sets the ceiling of the backoff for retries of an overloaded API error.A number of milliseconds. Whole number from 32000 to 64000 in plain digits, else unset. A longer wait than the ceiling plus a margin raises a retry-after errorAll API requests
CLAUDE_CODE_PROXY_RESOLVES_HOSTS
Documented: An official docs page names this item.
Lets the proxy resolve DNS names.On or off. When set the proxy agent lookup returns the host name as isHTTP proxy setups
CLAUDE_CODE_RETRY_WATCHDOG
Documented: An official docs page names this item.
Retries 429 and 529 capacity errors without end for unattended sessions. Docs match the code path that reads it.On or off. The self-hosted runner sets it to 1 and also clears CLAUDE_CODE_MAX_RETRIES. Docs also cover the spend-limit ruleUnattended runs, CI, remote workers. Set by Claude Code for self-hosted runners
CLAUDE_CODE_RETRY_WATCHDOG_USAGE_LIMIT_RECHECK_MS
Documented: An official docs page names this item.
Lets the retry watchdog notice a usage limit that was lifted before its reset. Added in 2.1.305 (v2.1.305 release). The program logs [usage limit recheck] lines when it sends or skips a probe request.A number of milliseconds. The program shows no format check in the stringsSessions with CLAUDE_CODE_RETRY_WATCHDOG
CLAUDE_CODE_RETRY_WATCHDOG_MAX_USAGE_LIMIT_WAIT_MS
Undocumented: Only the program shows this item. It can change without notice.
Caps the total ms that the retry watchdog waits for usage-limit 429 errors to end. When the wait is longer than what is left, the request fails.A number of milliseconds. Integer 1 or more, digits only. Unset means no limitSessions with the retry watchdog on
CLAUDE_CODE_RETRY_WATCHDOG_MAX_WAIT_MS
Documented: An official docs page names this item.
Caps the ms each API request spends waiting out 429 and 529 errors under the watchdog. After that the next error ends the request.A number of milliseconds. Integer 1 or more, digits only. Unset means no limitSessions with CLAUDE_CODE_RETRY_WATCHDOG. Docs say v2.1.295 or later
CLAUDE_CODE_RETRY_WATCHDOG_SCOPE
Undocumented: Only the program shows this item. It can change without notice.
Narrows the retry watchdog to capacity errors. New in 2.1.310. With capacity, the watchdog still retries 429 and 529 errors without end, but its other extensions are off: more retries after no response or a non-streaming timeout, keeping background requests on 529, and the server-error model fallback.Text. Only capacity has an effectSessions with CLAUDE_CODE_RETRY_WATCHDOG
CLAUDE_CODE_UNWATCHED_REPLY_HOLD_MS
Undocumented: Only the program shows this item. It can change without notice.
Holds the streamed reply of a subagent, an auxiliary, or a compaction request for up to this many ms before it passes the data on. Added in 2.1.311.A number of ms, 0 by default (no hold). Applies to content block delta and ping events. Held data goes on at 262144 bytesStreaming replies of subagent, auxiliary, and compaction requests
CLAUDE_ENABLE_BYTE_WATCHDOG
Documented: An official docs page names this item.
Forces the byte-level streaming idle watchdog on or off.On, off, or unset, on by default. Unset uses a feature flag with default true. Direct, AWS, and gateway onlyAnthropic API, AWS, gateway
CLAUDE_ENABLE_BYTE_WATCHDOG_BEDROCK
Documented: An official docs page names this item.
Enables the byte-level streaming idle watchdog for Bedrock event streams.On or off. Off by default. Needs the main watchdog to be onAmazon Bedrock
CLAUDE_ENABLE_STREAM_WATCHDOG
Documented: An official docs page names this item.
Forces the event-level streaming idle watchdog on or off. It also sets the async agent stall time.On, off, or unset, on by defaultAll sessions
CLAUDE_SLOW_FIRST_BYTE_MS
Undocumented: Only the program shows this item. It can change without notice.
Sets the wait before Claude Code logs a slow first byte on a stream. It does not abort.A number of milliseconds-
CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS
Documented: An official docs page names this item.
Sets the first-byte deadline of a streaming request in ms.A number of milliseconds-
CLAUDE_STREAM_IDLE_TIMEOUT_MS
Documented: An official docs page names this item.
Sets the idle timeout of the stream watchdogs in ms.A number of milliseconds-
CLOUDSDK_CORE_CUSTOM_CA_CERTS_FILE
Undocumented: Only the program shows this item. It can change without notice.
Names a CA bundle file for gcloud. The Bash sandbox treats it as a CA bundle variable.A path-
CURL_CA_BUNDLE
Undocumented: Only the program shows this item. It can change without notice.
Names a CA bundle for curl. The Bash sandbox treats it as a CA bundle variable.--
DENO_CERT
Undocumented: Only the program shows this item. It can change without notice.
Names a CA bundle for Deno. The Bash sandbox treats it as a CA bundle variable.--
GIT_SSL_CAINFO
Documented: An official docs page names this item.
Gives the Git CA bundle path. Claude Code names it in CA hints and in runner messages saying a server value replaces it in a session.Text. Use is mostly by name in text and listsGit. Self-hosted runner. Not set from project env before trust
HTTP_PROXY
Documented: An official docs page names this item.
Sets the HTTP proxy for Claude Code network traffic.--
http_proxy
Documented: An official docs page names this item.
Lower case HTTP proxy URL. Claude Code reads it as an alternative to HTTP_PROXY.Text. Non-empty string. Order is HTTP_PROXY, this, then CLAUDE_CODE_HTTP_PROXY for the sandbox proxyAll sessions
HTTPS_PROXY
Documented: An official docs page names this item.
Sets the HTTPS proxy for Claude Code network traffic.--
https_proxy
Documented: An official docs page names this item.
Lower case HTTPS proxy URL. Claude Code reads it as an alternative to HTTPS_PROXY.Text. Non-empty string. Order is HTTPS_PROXY, this, then CLAUDE_CODE_HTTPS_PROXY for the sandbox proxyAll sessions
NIX_SSL_CERT_FILE
Undocumented: Only the program shows this item. It can change without notice.
Claude Code sets it to the CA bundle path in sandboxed commands, with other CA variables.A path-
NO_PROXY
Documented: An official docs page names this item.
Lists hosts that skip the proxy. * skips it for all.On or off-
no_proxy
Documented: An official docs page names this item.
Lower case proxy bypass list. Claude Code reads it with NO_PROXY.A comma-separated list. If both are set and differ, Claude Code joins them with a commaAll sessions
NODE_EXTRA_CA_CERTS
Documented: An official docs page names this item.
Adds extra CA certificates from a PEM file to the trusted set.--
NODE_TLS_REJECT_UNAUTHORIZED
Documented: An official docs page names this item.
Set to 0 to turn off TLS certificate checks (Bun). Claude Code counts any value except 1 as a trust override.--
NODE_USE_ENV_PROXY
Undocumented: Only the program shows this item. It can change without notice.
A value other than empty or 0 makes the Bun http client use HTTP_PROXY and HTTPS_PROXY. A bundled proxy tip names it for Node 22.21 and later.--
NODE_USE_SYSTEM_CA
Undocumented: Only the program shows this item. It can change without notice.
The value 1 makes the Bun runtime add the OS CA store to the default CA list.--
SSL_CERT_DIR
Undocumented: Only the program shows this item. It can change without notice.
Gives the directory of CA certificates. Claude Code counts it as a custom CA setting.Text. Raw string (rawStr). Together with NODE_EXTRA_CA_CERTS and SSL_CERT_FILE, it makes the TLS setup treat custom certs as setAll sessions
SSL_CERT_FILE
Documented: An official docs page names this item.
Gives the CA bundle file path. Claude Code treats it as a custom CA setting, and passes it to proxy helpers and the MCP agent proxy.Text. Raw string. The MCP agent proxy fallback reads the file as PEMAll sessions

How It Works​

Claude Code reads shell variables once at startup, so restart after a change. Claude Code reapplies values in a settings env block when the file changes. It does not reapply them for features that read their variables only at startup. Numeric variables such as timeouts accept forms like 2e3 and 64_000 in addition to plain digits, except where a row says digits only.

Source: the program (variable names found in the 2.1.312 binary) and the Environment Variables page of the official docs.