Many people try to configure Cursor CLI proxy by running
export HTTP_PROXYorexport HTTPS_PROXY, only to find thatagentstill cannot call models. This guide explains why that happens and provides a more reliableproxychains4-based fix.
Language: English | 中文
Tip
Recommended: Give this document to Codex, Claude Code, Cursor, or another AI coding assistant, tell it your local proxy address, and let it configure Cursor CLI for you.
Use a one-line prompt like this:
My local proxy is socks5://127.0.0.1:7890. Please configure Cursor CLI proxy according to this document.
Replace the proxy address with your real one, for example:
socks5://127.0.0.1:10808
http://127.0.0.1:8080
On a fresh Linux machine, Cursor CLI may fail with:
Model not available
This model provider is not supported in your region.
This can happen even when a direct proxy test works:
curl -x http://127.0.0.1:10808 https://ipinfo.io/jsonThe confusing part is that curl can use the proxy, while agent still fails.
The reason is simple: Cursor Agent's real model request path is not necessarily covered by your shell-level HTTP_PROXY / HTTPS_PROXY variables.
The core goal of this guide is to solve one specific problem: Cursor CLI does not reliably use your proxy even after you export HTTP_PROXY in the shell.
After applying this guide:
agentuses the local proxy by default.- New terminal sessions do not need manual
export HTTP_PROXY/export HTTPS_PROXY. - Cursor Agent is not forced down to
HTTP/1.1. - Cursor Agent can keep its default network negotiation, usually allowing
HTTP/2. - Real GPT / Claude model requests go through the proxy path as well.
A common workaround is to inject a Node.js script and patch https.globalAgent.
That only covers part of Node's network stack. It may not reliably cover:
http2- gRPC
- streaming requests
- internal model-provider request paths
So you may see a half-working state:
- login works
- account info works
- model list works
- real model calls still fail
The approach in this document is different:
- Use
proxychains4as a TCP-level proxy wrapper. - Keep
useHttp1ForAgent: false. - Route the whole external TCP path of
agentthrough your local SOCKS5 / HTTP proxy.
The target path is:
agent
-> proxychains4
-> local proxy, for example socks5://127.0.0.1:10808
-> Cursor API / model providers
Not just:
agent
-> patched https.globalAgent
-> only some HTTPS requests use the proxy
This guide assumes:
- You are using Linux.
- Cursor CLI / Cursor Agent is installed, and
agentis available. - You already have a working local proxy, such as
127.0.0.1:10808. - You know whether the proxy is
socks5orhttp.
The examples below use:
protocol: socks5
host: 127.0.0.1
port: 10808
Check agent:
command -v agentCheck proxychains4:
command -v proxychains4Install it if needed.
Debian / Ubuntu:
sudo apt-get update
sudo apt-get install -y proxychains4CentOS / Rocky / RHEL:
sudo yum install -y proxychains-ngOr:
sudo dnf install -y proxychains-ngCheck your local proxy port:
ss -ltn | rg 10808Verify the proxy:
curl -x http://127.0.0.1:10808 https://ipinfo.io/jsonIf this fails, fix your local proxy first.
Run:
agent aboutIf you are not logged in yet:
agent loginThis should create or confirm these paths:
~/.cursor/~/.cursor/cli-config.json~/.local/bin/agent
Create ~/.cursor/proxychains-agent.conf:
mkdir -p ~/.cursor
cat > ~/.cursor/proxychains-agent.conf <<'EOF'
dynamic_chain
quiet_mode
proxy_dns
remote_dns_subnet 224
tcp_read_time_out 15000
tcp_connect_time_out 8000
localnet 127.0.0.0/255.0.0.0
localnet ::1/128
localnet 10.0.0.0/255.0.0.0
localnet 172.16.0.0/255.240.0.0
localnet 192.168.0.0/255.255.0.0
[ProxyList]
socks5 127.0.0.1 10808
EOFNotes:
quiet_modereduces noisy proxychains logs.proxy_dnshelps avoid DNS leaks.localnetprevents loopback and private network traffic from being sent through the proxy.[ProxyList]is where you set your real proxy endpoint.
Open:
~/.cursor/cli-config.json
Make sure it contains:
"network": {
"useHttp1ForAgent": false
}The key point:
falsemeans Cursor Agent is not forced to useHTTP/1.1.- Cursor Agent can use its default behavior, usually negotiating
HTTP/2when available.
Check quickly:
rg -n '"useHttp1ForAgent"' ~/.cursor/cli-config.jsonRun:
readlink -f ~/.local/bin/agentYou may see something like:
/home/<user>/.local/share/cursor-agent/versions/2026.04.15-dccdccd/cursor-agent
This is the real script currently executed by agent.
REAL_AGENT="$(readlink -f ~/.local/bin/agent)"
cp "$REAL_AGENT" "${REAL_AGENT}.bak"Overwrite $REAL_AGENT with:
REAL_AGENT="$(readlink -f ~/.local/bin/agent)"
cat > "$REAL_AGENT" <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
export CURSOR_INVOKED_AS="$(basename "$0")"
if command -v realpath >/dev/null 2>&1; then
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
else
SCRIPT_DIR="$(dirname "$(readlink "$0" || echo "$0")")"
fi
NODE_BIN="$SCRIPT_DIR/node"
if [ -z "${NODE_COMPILE_CACHE:-}" ]; then
if [[ "${OSTYPE:-}" == darwin* ]]; then
export NODE_COMPILE_CACHE="$HOME/Library/Caches/cursor-compile-cache"
else
export NODE_COMPILE_CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/cursor-compile-cache"
fi
fi
PROXYCHAINS_BIN=""
if command -v proxychains4 >/dev/null 2>&1; then
PROXYCHAINS_BIN="$(command -v proxychains4)"
elif command -v proxychains >/dev/null 2>&1; then
PROXYCHAINS_BIN="$(command -v proxychains)"
fi
PROXYCHAINS_CONFIG="${CURSOR_AGENT_PROXYCHAINS_CONFIG:-$HOME/.cursor/proxychains-agent.conf}"
if [ -n "$PROXYCHAINS_BIN" ] && [ -f "$PROXYCHAINS_CONFIG" ] && [ "${CURSOR_AGENT_DISABLE_PROXYCHAINS:-0}" != "1" ]; then
exec -a "$0" "$PROXYCHAINS_BIN" -q -f "$PROXYCHAINS_CONFIG" \
"$NODE_BIN" --use-system-ca "$SCRIPT_DIR/index.js" "$@"
fi
exec -a "$0" "$NODE_BIN" --use-system-ca "$SCRIPT_DIR/index.js" "$@"
EOF
chmod +x "$REAL_AGENT"REAL_AGENT="$(readlink -f ~/.local/bin/agent)"
rg -n 'proxychains4|proxychains-agent.conf|CURSOR_AGENT_DISABLE_PROXYCHAINS' "$REAL_AGENT"You should see these keywords in the startup script.
Check basic information:
agent aboutTest a model request:
agent -p --output-format text --model gpt-5.4-medium helloTest another provider if available:
agent -p --output-format text --model claude-4.6-opus-max-thinking helloModel names may change depending on Cursor CLI and your account. If a sample model is unavailable, use a model that your account can access.
Verify that agent no longer depends on shell proxy variables:
unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy ALL_PROXY all_proxy
agent aboutIf this still works, the proxy is coming from proxychains-agent.conf, not from shell export.
Only edit:
~/.cursor/proxychains-agent.conf
Default:
[ProxyList]
socks5 127.0.0.1 10808Use port 7890:
[ProxyList]
socks5 127.0.0.1 7890Use another machine:
[ProxyList]
socks5 192.168.1.50 10808Use an HTTP proxy:
[ProxyList]
http 127.0.0.1 8080Then start a new agent session:
agentCursor Agent updates may replace the real script path:
~/.local/share/cursor-agent/versions/<new-version>/cursor-agent
After an update, check:
readlink -f ~/.local/bin/agentThen verify whether the patch is still present:
REAL_AGENT="$(readlink -f ~/.local/bin/agent)"
rg -n 'proxychains4|proxychains-agent.conf' "$REAL_AGENT"If there is no output, repeat the patch step.
Disable proxychains for one run:
CURSOR_AGENT_DISABLE_PROXYCHAINS=1 agentUse another proxychains config for one run:
CURSOR_AGENT_PROXYCHAINS_CONFIG=/path/to/another.conf agentRestore the backed-up startup script:
REAL_AGENT="$(readlink -f ~/.local/bin/agent)"
cp "${REAL_AGENT}.bak" "$REAL_AGENT"
chmod +x "$REAL_AGENT"If you only need an emergency fallback, you can change:
"useHttp1ForAgent": falseback to:
"useHttp1ForAgent": trueThis forces HTTP/1.1. It may work around some issues, but it is not the main solution recommended here.
If agent about hangs:
command -v proxychains4
test -f ~/.cursor/proxychains-agent.conf && echo ok
ss -ltn | rg '10808|7890|8080'If model list works but real model calls still fail:
REAL_AGENT="$(readlink -f ~/.local/bin/agent)"
rg -n 'proxychains4|proxychains-agent.conf' "$REAL_AGENT"If you changed the port but Cursor still uses the old one:
sed -n '1,80p' ~/.cursor/proxychains-agent.confMake sure you edited the Cursor-specific config, not only:
/etc/proxychains4.conf
If agent works but curl does not use the proxy, that is expected. This guide only configures Cursor Agent. Other tools such as curl, git, npm, and pip still need their own proxy configuration.
Before considering the setup complete, check:
agentis installed and logged in.proxychains4is installed.- The local proxy port is working.
~/.cursor/proxychains-agent.confexists and points to the correct endpoint.~/.cursor/cli-config.jsonhasuseHttp1ForAgentset tofalse.- The active
cursor-agentstartup script contains theproxychains4logic.
The fix is not simply "set HTTP_PROXY" or "force HTTP/1.1".
The more reliable approach is to route Cursor Agent through proxychains4 + local proxy at the TCP layer. This keeps Cursor Agent's default network behavior while avoiding the incomplete coverage of patching only https.globalAgent.