Getting StartedClaude CodeCommon ErrorsNetwork Diagnosis

Network Diagnosis and API Endpoint Selection Guide

Have you ever experienced slow Claude Code requests, timeouts, or failures? These issues are often not caused by the server, but by a specific link in the complex network chain. This guide will help you fully understand how the network works, develop diagnostic skills, identify the root cause of problems, and choose the best API endpoint for your situation.

Understanding the Full Request Chain

When we send a request in Claude Code, the data passes through the following steps:

Our Computer → Local Network → ISP Network → International Gateway → Overseas Network → CC Club Server → Anthropic API

                           Most likely point of failure
LinkPotential IssuesSymptoms
Local NetworkWeak WiFi signal, router issuesAll websites are slow
ISP NetworkLine congestion, DNS pollutionSlow at specific times
International GatewayBandwidth limits, policy interferenceOnly overseas services are slow
VPN/ProxyCrowded nodes, routing detoursDifferent behavior with VPN on/off
CC Club ServerServer load (very rare)All users report issues simultaneously

Based on our statistics, over 90% of “slow request” problems originate from the client network environment, not the server side.

The Complexity of China’s Outbound Internet

Why Is It So Hard to Access Overseas Services?

China’s international internet gateways are limited, and all outbound traffic must pass through a few major nodes:

  1. The three major ISPs have limited international bandwidth: Especially congested during peak hours (8–11 PM)
  2. Significant differences between ISPs: China Telecom, Unicom, and Mobile have noticeably different line quality to different regions
  3. Geographic impact: Coastal cities generally have faster overseas access than inland cities
  4. Policy interference: Outbound networks can become particularly unstable during certain periods

Characteristics of Different ISPs

ISPTo JapanTo Hong KongNotes
China TelecomGoodAverageCN2 line has the best quality
China UnicomAverageGoodLarge fluctuations during peak hours
China MobileAverageGoodCMI line is relatively stable
⚠️

These are general patterns — actual performance varies by region and time of day. The most reliable approach is to test yourself.

Comprehensive Network Diagnosis Guide

Step 1: Rule Out Local Network Issues

First, confirm your local network is functioning normally:

# Test local network connectivity
ping -c 5 baidu.com
 
# If this fails, there is a local network issue

Normal result: 0% packet loss, latency < 50ms

Step 2: Test Network Quality to Each API Endpoint

CC Club provides three API endpoints. Test which one works best for you:

EndpointServer LocationCloud ProviderNotes
https://claude-code.club/apiJapan (Tokyo)AWSDefault address, good stability
https://jp.claude-code.club/apiJapanAlibaba CloudOptimized routing
https://hk.claude-code.club/apiHong KongAlibaba CloudOptimized routing

How to Choose the Best Node?

  • Direct connection latency < 100ms: If your ping to claude-code.club is under 100ms, your outbound network is clear. Using the default claude-code.club address is fastest because the path is shortest.
  • Outbound congestion or high latency: If the direct connection latency exceeds 200ms or packet loss is severe, try the Alibaba Cloud jp or hk nodes. Generally, users in eastern/northern China are recommended to use the jp node, and users in southern China the hk node — but this can vary by ISP, so test both.

Ping Test (Basic Connectivity)

⚠️

Note: Ping only measures your latency to the proxy server — it does not include the path from the proxy server to the AI model API. Low ping latency does not mean fast actual requests. To test true end-to-end latency, use the Curl Test below.

# Test each node (30 packets each, more accurate)
echo "=== Default Node (AWS Tokyo) ===" && ping -c 30 claude-code.club
echo "=== Japan Node (Alibaba Cloud) ===" && ping -c 30 jp.claude-code.club
echo "=== Hong Kong Node (Alibaba Cloud) ===" && ping -c 30 hk.claude-code.club

How to Interpret the Results:

--- claude-code.club ping statistics ---
7 packets transmitted, 6 packets received, 14.3% packet loss
round-trip min/avg/max/stddev = 85.010/85.833/87.800/0.931 ms
  • Packet loss: < 2% excellent, 2–5% acceptable, > 5% poor
  • Average latency (avg): < 100ms excellent, 100–200ms acceptable, > 200ms slow
  • Latency variance (mdev/jitter): Smaller is more stable

MTR Test (Trace the Full Path)

MTR is more powerful than ping — it shows every hop the packet takes:

# Install mtr (if not installed)
brew install mtr
 
# Test the path to each node
sudo mtr -r -c 30 claude-code.club
sudo mtr -r -c 30 jp.claude-code.club
sudo mtr -r -c 30 hk.claude-code.club

Interpreting MTR Output:

Host                          Loss%   Snt   Last   Avg  Best  Wrst StDev
1. 192.168.1.1                 0.0%    30    1.2   1.5   0.8   3.2   0.5   ← Our router
2. 10.0.0.1                    0.0%    30    5.3   6.1   4.2   8.7   1.2   ← ISP gateway
3. 202.97.xxx.xxx              3.3%    30   30.5  35.2  28.1  52.3   6.8   ← ISP backbone
4. 202.97.xxx.xxx             10.0%    30   45.2  48.6  42.1  68.9   8.2   ← International gateway ⚠️
5. ...

Key points:

  • Look for which hop introduces high packet loss or high latency
  • 202.97.x.x is typically China Telecom backbone
  • 219.158.x.x is typically China Unicom backbone
  • Heavy packet loss at the international gateway indicates outbound bandwidth issues

This is the most accurate test method! A curl test actually accesses the API endpoint and measures the complete end-to-end latency, including: your network → proxy server → Anthropic API → response. This truly reflects the actual speed of each node.

Quick Test (Recommended):

# Use the time command to measure total request time
time curl -s https://claude-code.club/api/health
time curl -s https://jp.claude-code.club/api/health
time curl -s https://hk.claude-code.club/api/health

Sample output:

{"status":"healthy","service":"claude-relay-service",...}
curl -s https://claude-code.club/api/health  0.01s user 0.01s system 6% cpu 0.243 total

                                                            Real end-to-end latency (243ms)

Detailed Test (View time per stage):

# Test HTTP response time for each node (by stage)
echo "=== Default Node ===" && curl -w "DNS: %{time_namelookup}s, Connect: %{time_connect}s, TTFB: %{time_starttransfer}s, Total: %{time_total}s\n" -o /dev/null -s https://claude-code.club/api/health
 
echo "=== Japan Node ===" && curl -w "DNS: %{time_namelookup}s, Connect: %{time_connect}s, TTFB: %{time_starttransfer}s, Total: %{time_total}s\n" -o /dev/null -s https://jp.claude-code.club/api/health
 
echo "=== Hong Kong Node ===" && curl -w "DNS: %{time_namelookup}s, Connect: %{time_connect}s, TTFB: %{time_starttransfer}s, Total: %{time_total}s\n" -o /dev/null -s https://hk.claude-code.club/api/health

Interpreting each metric:

  • DNS: Domain resolution time, should be < 0.1s
  • Connect: TCP handshake time, reflects network latency between you and the proxy server
  • TTFB: Time to first byte, reflects proxy server processing + latency to the AI model API
  • Total: Full request time — this is the most important metric, should be < 1s

TLS Handshake Check (Detect Connection Interception)

Some regional ISPs intercept or interfere with outbound HTTPS requests during the TLS handshake. Use curl -v to view the complete connection process and determine whether interception is occurring:

# Verbose mode test (-v shows the full handshake process)
curl -v https://claude-code.club/api/health

Sample normal TLS handshake output:

* Host claude-code.club:443 was resolved.
* IPv4: 54.250.224.68
*   Trying 54.250.224.68:443...
* Connected to claude-code.club (54.250.224.68) port 443
* ALPN: curl offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/cert.pem
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256
* ALPN: server accepted h2
* Server certificate:
*  subject: CN=claude-code.club
*  start date: Dec 22 14:32:56 2025 GMT
*  expire date: Mar 22 14:32:55 2026 GMT
*  issuer: C=US; O=Let's Encrypt; CN=E7
*  SSL certificate verify ok.
* using HTTP/2
< HTTP/2 200

Interpreting Key Information:

OutputMeaningExpected Value
Connected to ... port 443TCP connection successfulShould show the target IP
TLS handshake, Client helloClient initiates TLS handshakeMust appear
TLS handshake, Server helloServer responds to handshakeMust appear
TLS handshake, CertificateServer sends certificateMust appear
SSL certificate verify okCertificate verification passedMust appear
TLSv1.3TLS version1.2 or 1.3
issuer: ... Let's EncryptCertificate authorityShould be Let’s Encrypt
HTTP/2 200Request successfulStatus code 200

Abnormal Situations and Diagnosis:

⚠️

If any of the following occur, the connection may be intercepted or interfered with:

1. Connection timeout or reset

* connect to 54.250.224.68 port 443 failed: Connection timed out
* Failed to connect to claude-code.club port 443: Connection refused
* Connection reset by peer

Cause: ISP may be blocking the connection at the TCP layer

2. TLS handshake failure

* TLS handshake, Client hello (1):
* OpenSSL SSL_connect: Connection reset by peer
* Closing connection 0
curl: (35) OpenSSL SSL_connect: Connection reset by peer

Cause: ISP sends a RST packet during TLS handshake to interrupt the connection — this is typical SNI blocking

3. Abnormal certificate issuer

* Server certificate:
*  subject: CN=claude-code.club
*  issuer: C=CN; O=China Internet Network Information Center; CN=...

Cause: If the certificate issuer is not Let's Encrypt but another organization (especially a Chinese one), there may be a man-in-the-middle attack or SSL hijacking

4. Certificate verification failure

* SSL certificate problem: unable to get local issuer certificate
* SSL certificate problem: self signed certificate in certificate chain

Cause: May be a local certificate store issue or traffic hijacking

5. Long wait followed by failure

* TLS handshake, Client hello (1):
[Long wait...]
curl: (28) Operation timed out after 30000 milliseconds

Cause: Request is “black-holed” — packets are silently dropped with no response

What to Do If Intercepted?

  1. Switch nodes: Try other API endpoints (jp.claude-code.club or hk.claude-code.club)
  2. Use a proxy: Bypass interception with a VPN or proxy
  3. Switch networks: Try a mobile hotspot or a different ISP’s network
  4. Change DNS: Use 1.1.1.1 (Cloudflare) or 223.5.5.5 (Alibaba Cloud) to avoid DNS pollution

Step 3: Continuous Monitoring Test

Network conditions change over time. It is recommended to test at different times of day:

# Test every 5 seconds for 1 minute (12 times)
for i in {1..12}; do
    echo "$(date '+%H:%M:%S') - Test #$i"
    curl -w "Total: %{time_total}s\n" -o /dev/null -s https://claude-code.club/api/health
    sleep 5
done

Common Scenarios and Solutions

Scenario 1: All Nodes Are Slow

Possible causes:

  • Local network issue
  • ISP overall outbound bandwidth congestion
  • VPN node poor quality

Solutions:

  1. Check local WiFi/network connection
  2. Try switching to a mobile hotspot
  3. If using VPN, try switching nodes or disabling VPN for a direct connection test

Scenario 2: One Node Is Particularly Slow, Others Are Fine

Possible cause: Poor ISP line quality to that region

Solution: Choose the node with the best test results

Scenario 3: Fine During the Day, Slow at Night

Possible cause: Peak hour (20:00–23:00) outbound bandwidth congestion

Solutions:

  1. Try switching to a different node
  2. Use it during off-peak hours
  3. Use a VPN to bypass congested routes

Scenario 4: Intermittent — Sometimes Good, Sometimes Bad

Possible causes:

  • Network quality fluctuations
  • VPN node load changes
  • Routing changes

Solutions:

  1. Choose the node with the lowest latency variance (mdev/jitter)
  2. If using VPN, select a more stable node

Scenario 5: Slower with VPN Than Without

Possible causes:

  • VPN node overcrowded
  • Routing detour (e.g., you are in Shanghai, VPN routes through the US then to Singapore)
  • VPN node bandwidth insufficient

Solutions:

  1. Choose VPN nodes close to the API server (Japan, Hong Kong, Singapore)
  2. Test without VPN (direct connection) for comparison
  3. Switch VPN providers or nodes

Understanding Proxy Tool Configuration Modes

Many users use proxy tools like Clash Verge, ClashX, or Surge without fully understanding how they work, leading to misconfiguration and network issues. Sometimes enabling a proxy can actually make things worse — understanding proxy configuration modes is critical.

The Three Proxy Modes

Using Clash Verge as an example, proxy tools typically provide three modes:

ModeHow It WorksScopeDoes It Affect Terminal Tools?
System ProxyModifies system proxy settings so apps that support system proxy route through itBrowsers, some GUI appsNo
TUN Mode (Tunnel Mode)Creates a virtual network card that intercepts all traffic at the network layerAll network trafficYes (forced)
Environment Variable ProxySets http_proxy and similar environment variables; terminal tools read and use themCurrent terminal session onlyYes
⚠️

Note: All three modes can be active simultaneously! If TUN mode and environment variable proxy are both active, traffic may be proxied twice, causing connection failures or slower speeds.

How Terminal Tools (Claude Code, Gemini CLI, etc.) Use a Proxy

Claude Code, Codex, Gemini CLI, and similar terminal tools do not automatically use the system proxy. They rely on:

  1. Environment variables: Reading http_proxy, https_proxy, HTTP_PROXY, HTTPS_PROXY, etc.
  2. TUN mode: If the proxy tool has TUN mode enabled, all traffic (including terminal) is forcibly intercepted

Configuring Environment Variable Proxy

If you need terminal tools to use a proxy, set environment variables:

Method 1: Create a config file, load on demand

# Create a proxy config file
cat > ~/.proxy << 'EOF'
export http_proxy=http://127.0.0.1:7897
export https_proxy=http://127.0.0.1:7897
export HTTP_PROXY=http://127.0.0.1:7897
export HTTPS_PROXY=http://127.0.0.1:7897
export all_proxy=socks5://127.0.0.1:7897
export NO_PROXY=localhost,127.0.0.1,::1
EOF
 
# Create an unset proxy config file
cat > ~/.unset_proxy << 'EOF'
unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY all_proxy NO_PROXY
EOF

Usage:

# Enable proxy (takes effect in the current terminal)
source ~/.proxy
 
# Verify proxy is active
echo $http_proxy
# Output: http://127.0.0.1:7897
 
# Disable proxy
source ~/.unset_proxy
 
# Verify proxy is disabled
echo $http_proxy
# Output: (empty)

Method 2: Define shortcut commands

Add to ~/.zshrc or ~/.bashrc:

# Proxy toggle shortcuts
alias proxy_on='export http_proxy=http://127.0.0.1:7897 https_proxy=http://127.0.0.1:7897 all_proxy=socks5://127.0.0.1:7897'
alias proxy_off='unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY all_proxy NO_PROXY'
alias proxy_status='echo "http_proxy=$http_proxy"'

Then run source ~/.zshrc to apply. Afterwards use proxy_on, proxy_off, and proxy_status to toggle quickly.

Port 7897 is the default port for Clash Verge. If you use a different proxy tool, check its settings for the local port number. Common ports: Clash 7890, ClashX 7890, V2rayN 10809, Surge 6152.

Check Current Proxy Status

When diagnosing network issues, first clarify your current proxy configuration:

# Check environment variable proxy
echo "http_proxy: $http_proxy"
echo "https_proxy: $https_proxy"
echo "HTTP_PROXY: $HTTP_PROXY"
echo "HTTPS_PROXY: $HTTPS_PROXY"
 
# Check which path the request actually takes
curl -v https://claude-code.club/api/health 2>&1 | grep -E "(Trying|Connected|proxy)"

Based on different scenarios, here are the recommended configurations:

ScenarioSystem ProxyTUN ModeEnv VarsNotes
Direct connection testOffOffNoneTest raw performance
Browser only through proxyOnOffNoneTerminal connects directly
Terminal through proxyOffOffSetEnable on demand
Global proxyOffOnNoneAll traffic through proxy
AvoidOnOnSetMay conflict!
⚠️

Common Mistake: Enabling TUN mode and setting environment variable proxy simultaneously, causing traffic to be proxied twice, resulting in request failures or abnormally slow speeds. If you have TUN mode enabled, make sure to clear the environment variable proxy.

Test Whether Proxy Is Working

# Direct request without proxy (for comparison)
curl --noproxy '*' -w "Total: %{time_total}s\n" -o /dev/null -s https://claude-code.club/api/health
 
# Request through proxy (if environment variables are set)
curl -w "Total: %{time_total}s\n" -o /dev/null -s https://claude-code.club/api/health
 
# Force use of a specific proxy
curl -x http://127.0.0.1:7897 -w "Total: %{time_total}s\n" -o /dev/null -s https://claude-code.club/api/health

Compare the response times of all three approaches and choose the fastest configuration.

End-to-End Test Using Claude Code

The ping and curl tests above only verify network connectivity. To test the actual working condition of the API, send a simple request directly with Claude Code:

# Use the time command to measure the full request time
time claude --model claude-haiku-4-5-20251001 -p "hi"

Sample output:

Hi! How can I help you today?

real    0m2.847s    ← Total time (key metric)
user    0m0.312s
sys     0m0.089s

How to interpret:

real TimeStatusNotes
< 10sExcellentNetwork and API are both normal
10–18sAcceptableSlight delays possible
18–25sSlowNetwork congestion or node issue
> 25s or timeoutAbnormalInvestigate network or switch node

Using the claude-haiku-4-5-20251001 model because Haiku responds fastest and consumes the fewest tokens, making it ideal for network testing. This test will consume a small amount of tokens but accurately reflects the end-to-end API latency.

Compare different configurations:

# 1. Direct connection test (disable proxy first)
source ~/.unset_proxy
time claude --model claude-haiku-4-5-20251001 -p "hi"
 
# 2. Proxy test (enable proxy)
source ~/.proxy
time claude --model claude-haiku-4-5-20251001 -p "hi"

Compare the real times and choose the faster configuration.

Collect Debug Logs for Admin Analysis

If the above methods do not resolve the issue, use Claude Code’s debug mode to collect detailed logs and send them to an administrator for deep analysis.

Collect debug logs:

# Send a test request in debug mode and collect complete logs
claude --debug-file /tmp/claude-network-debug.log \
      --debug "api,mcp" \
      --model claude-haiku-4-5-20251001 \
      -p "test network connection"

After collection, the log is saved to /tmp/claude-network-debug.log

# View the log content
cat /tmp/claude-network-debug.log
 
# Send the log to an administrator (copy content or send the file)

Parameter Reference:

ParameterDescription
--debug-fileSpecify the log file path
--debug "api,mcp"Enable detailed debug info for API and MCP
--model claude-haiku-4-5-20251001Use the fastest model to minimize wait time
-p "test network connection"Send a simple test message

Key information in the logs:

  • Complete HTTP request and response details
  • Network connection establishment process
  • TLS handshake details
  • API call timing and duration
  • Error stack traces (if any)
  • MCP server connection status
⚠️

Debug logs may contain sensitive information (such as API key fragments, request paths, etc.). Review the log content before sending to an administrator, or upload securely via CC Club’s support system.

Using the Haiku model minimizes token consumption and wait time while still generating a complete network request log. This test consumes very few tokens.

Choosing the Best API Endpoint

Based on your test results, select the most suitable endpoint:

Run the Full Test

Following the steps above, test ping and curl response times for all three nodes.

Compare Results

Select the node with the lowest packet loss, lowest average latency, and smallest latency variance.

Update Configuration

Set ANTHROPIC_BASE_URL to the best node:

# If the default node is fastest (direct connection latency < 100ms)
export ANTHROPIC_BASE_URL="https://claude-code.club/api"
 
# If the Japan node is fastest
export ANTHROPIC_BASE_URL="https://jp.claude-code.club/api"
 
# If the Hong Kong node is fastest
export ANTHROPIC_BASE_URL="https://hk.claude-code.club/api"

For detailed setup instructions, refer to:

Review Periodically

Network conditions change over time. If things feel slow, retest and adjust.

General Recommendations

  1. Prefer direct connection when the network is clear: If your ping to claude-code.club is under 100ms with low packet loss, using the default address is fastest — the path is shortest with the fewest intermediate hops
  2. Choose the nearest node: In general, geographic proximity means lower latency (though not always)
  3. Avoid peak hours: If possible, avoid the 8–11 PM network peak hours
  4. Keep multiple options: Remember several available nodes so you can switch quickly when one fails
  5. Update DNS: Use a reliable public DNS (such as 1.1.1.1 from Cloudflare or 223.5.5.5 from Alibaba Cloud)

Network diagnostics is a complex technical domain. If you still have questions after following this guide, feel free to share your test results (ping, mtr, curl output) in the community group and we will help you analyze them.

Summary

When API requests are slow, troubleshoot in the following order:

  1. Confirm local network is functioning normally
  2. Check proxy configuration status (ensure environment variables and TUN mode are not conflicting)
  3. Test network quality to each API endpoint
  4. Use curl -v to check whether TLS handshake is normal
  5. Use MTR to trace which hop is causing the problem
  6. Based on test results, select the best node
  7. Flexibly switch proxy configuration and compare direct vs. proxied performance

Remember: 90% of network problems occur on the link between the client and the server — mastering diagnostic skills helps us quickly identify and resolve issues.


MIT 2026 © Nextra.
加入社群CC Club返回官网