Troubleshooting Network Connectivity and Proxy Configuration for AI Coding Tools

    This guide explains why an AI coding tool may start normally but fail on remote requests, and how to fix it through proxy configuration rather than reinstalling the tool. It covers the typical request chain and four common root causes, how to verify that your local proxy exit works with curl, the exact user-level settings.json structure and what each field does (API_TIMEOUT_MS, HTTP_PROXY, HTTPS_PROXY, and related options), how to set system-level environment variables so the settings are inherited, a layered verification sequence from config parsing to in-app requests, and long-term practices for enterprise networks plus common mistakes to avoid.

    1. Symptoms and Root Cause Analysis

    After installing an AI coding tool (referred to below as “the tool”), some developers find that it launches normally but cannot issue remote requests: the interface opens, commands run, but anything involving model inference, dependency fetching, or account validation either hangs for a long time or fails with a connection error. To solve this, set aside the intuitive “the software is broken” judgment and look at the actual path a network request takes.

    A typical remote call passes through these stages in order: the process issues the request → the proxy settings in environment variables are read → the local proxy client → the corporate gateway or firewall → the target service endpoint. A missing link at any stage shows up as “cannot connect.” The common root causes fall into four categories:

    • Missing proxy environment variables: the tool process never inherits a proxy address, so requests go out directly and are blocked.
    • Malformed proxy configuration: the address lacks a protocol prefix, the port is missing, or quotes and spaces are misplaced, so parsing fails.
    • Timeout threshold too short: on cross-border or high-latency links, the handshake and time-to-first-byte exceed the default threshold and are treated as failures.
    • Local proxy client not running, or listening on a different port: the port in the configuration does not match the port actually being listened on.

    It is worth stressing that the tool itself usually only reads environment variables and hands them to the underlying network library; it has no built-in tunneling capability. So the fix is not to modify the tool, but to complete the network exit and the parameter configuration.

    2. Preparation: Confirm the Local Network Exit Works

    Before touching any configuration file, verify that the exit path itself is healthy; otherwise every later change is guesswork. Check in this order:

    1. Confirm the local proxy client is running, and look up its listening address and port in its settings (commonly a loopback address on the machine plus a high port).
    2. Verify from the command line that the proxy actually works:
    1. # Reach a general connectivity check endpoint through the proxy
    2. curl -x http://127.0.0.1:7890 -I https://www.example.com
    3. # Compare with a direct connection, no proxy
    4. curl -I https://www.example.com

    If the first command returns a status line while the second times out, the exit depends on the proxy, and you must inject the proxy into the tool process explicitly. If both fail, the problem is in the proxy client or the upstream path, and you should fix the client first.

    3. Core Fix: Locate and Edit the User-Level Configuration File

    The user-level configuration for the tool generally lives in a hidden configuration directory under the user home directory, with paths like these (the user directory differs by operating system):

    1. Windows: C:\Users\<your-username>\.claude\setting.json
    2. macOS/Linux: ~/.claude/setting.json

    Here <your-username> or ~ stands for the current logged-in user directory. If the directory or file does not exist, create it manually. Make sure the extension is .json and that your editor does not silently append .txt.

    Write the following structure into the file (illustrative; replace the port with the one your local client actually listens on):

    1. {
    2. "env": {
    3. "API_TIMEOUT_MS": "3000000",
    4. "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1,
    5. "HTTP_PROXY": "http://127.0.0.1:7890",
    6. "HTTPS_PROXY": "http://127.0.0.1:7890"
    7. },
    8. "hasCompletedOnboarding": true,
    9. "autoUpdatesChannel": "latest"
    10. }

    What each field does:

    • API_TIMEOUT_MS: the per-request timeout ceiling, in milliseconds. The original value 3000000 is roughly 50 minutes, which suits long inference tasks on high-latency links; for everyday use you can lower it to 120000 (2 minutes) to fail and retry faster.
    • CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: setting it to 1 turns off non-essential telemetry and background reporting, reducing unrelated traffic on the path and lowering the chance of being blocked by the gateway.
    • HTTP_PROXY / HTTPS_PROXY: specify the proxy exit for plaintext and encrypted requests respectively. Both must be filled in and correctly formatted — this is the most error-prone part of the original setup, where these two values were blank or placeholder text; after parsing, the tool behaves as if no proxy exists, so of course it cannot connect.
    • hasCompletedOnboarding: marks the initial onboarding as complete, so the tool does not repeat the onboarding flow on every launch and stall on the connectivity check.
    • autoUpdatesChannel: selects the auto-update channel; setting it to the stable channel reduces interference from background update requests.

    Formatting notes: JSON requires double quotes, no trailing commas, and paired keys and values. After saving, validate the syntax with any JSON validator or with python -m json.tool setting.json on the command line, so a single comma does not invalidate the whole file.

    4. Making the Configuration Actually Take Effect: Environment Variables and Process Inheritance

    The configuration file is not read in every scenario, especially when the tool is launched from a script, a container, or an IDE’s built-in terminal. The safer approach is to also set system-level environment variables as a second layer of insurance:

    1. # Linux/macOS, effective for the current session
    2. export HTTP_PROXY=http://127.0.0.1:7890
    3. export HTTPS_PROXY=http://127.0.0.1:7890
    4. export NO_PROXY=localhost,127.0.0.1,.internal.example.com
    5. # Windows PowerShell, effective for the current session
    6. $env:HTTP_PROXY="http://127.0.0.1:7890"
    7. $env:HTTPS_PROXY="http://127.0.0.1:7890"

    NO_PROXY excludes internal and local addresses so that requests to internal services are not wrongly forwarded to the proxy — a frequent pitfall in corporate environments. After setting these, you must fully exit and restart the tool process, because environment variables are snapshotted when the process starts and hot changes do not apply.

    5. Verification and Layered Troubleshooting

    Once the configuration is in place, verify from nearest to farthest so you can pinpoint the break quickly:

    1. Config parsing check: after starting the tool, inspect its logs or diagnostic output to confirm the proxy address has been loaded.
    2. Port listening check: netstat -ano | findstr 7890 (Windows) or lsof -i:7890 (Unix-like) to confirm the port is in a listening state.
    3. Path connectivity check: rerun the curl commands above and see whether a 2xx/3xx status line comes back.
    4. In-tool connectivity check: issue one minimal request (such as a version query or a lightweight chat) and see whether it returns within the timeout threshold.

    If step 3 passes but step 4 fails, the problem is usually certificate validation or endpoint allowlisting on the tool side; if step 2 already fails, go back and troubleshoot the proxy client.

    6. Enterprise-Scale and Long-Term Maintenance Practices

    In team or corporate networks, turn the above into a standard: put the proxy address and timeout parameters under unified environment configuration management and distribute them via images or initialization scripts instead of editing each machine by hand; relax the timeout threshold consistently for high-latency links and pair it with retry and backoff strategies; disable non-essential telemetry to narrow the outbound request list so the gateway can allow precisely what is needed. Logging services and monitoring alerts can also track the connection failure rate over time, surfacing anomalies before a failure spreads.

    If your environment does not permit an external proxy at all, use a compliant dedicated line or a controlled exit instead, with the network administrators opening the required endpoints centrally, rather than repeatedly attempting to bypass policy from the client.

    7. Common Mistakes

    • Filling in only HTTPS_PROXY and omitting HTTP_PROXY, so some requests still go direct.
    • Writing the proxy address as 127.0.0.1:7890 without the http:// prefix, which fails to parse.
    • Not restarting the process after editing the configuration, then assuming the configuration has no effect.
    • Setting the timeout too long, so a failure produces no feedback for a long time and becomes harder to diagnose.
    • Omitting internal domains from NO_PROXY, which breaks access to internal endpoints.

    Handle the steps in the order above, and the vast majority of “cannot connect after installation” issues can be closed out at the configuration level, with no need to reinstall the tool or change business code.