openclaw - 💡(How to fix) Fix [Feature]: Smart proxy detection - fallback to direct connection when proxy unavailable [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#68871Fetched 2026-04-19 15:06:42
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

Auto-detect proxy reachability before using it, fall back to direct connection when proxy port is closed

Root Cause

Auto-detect proxy reachability before using it, fall back to direct connection when proxy port is closed

Fix Action

Fix / Workaround

  1. Manual workaround: unset HTTPS_PROXY after closing proxy\n2. Keep proxy always on\n3. Modify node_modules directly (gets overwritten)
RAW_BUFFERClick to expand / collapse

Summary

Auto-detect proxy reachability before using it, fall back to direct connection when proxy port is closed

Problem to solve

When a proxy (e.g., Clash Verge) is enabled, OpenClaw correctly uses it. But when the proxy is closed, OpenClaw still tries to connect to the proxy address (e.g., 127.0.0.1:1080), causing ECONNREFUSED errors.

Proposed solution

In gaxios-fetch-compat.ts, modify resolveProxyUri() to check if the proxy port is reachable before using it. Add isProxyReachable() function that attempts TCP connection to proxy address. If unreachable, return undefined so axios uses direct connection.

Alternatives considered

  1. Manual workaround: unset HTTPS_PROXY after closing proxy\n2. Keep proxy always on\n3. Modify node_modules directly (gets overwritten)

Impact

Affected: Users who use proxy managers\nSeverity: Medium\nFrequency: Daily\nConsequence: ECONNREFUSED errors

Evidence/examples

No response

Additional information

No response

extent analysis

TL;DR

Modify the resolveProxyUri() function in gaxios-fetch-compat.ts to check if the proxy port is reachable before using it, falling back to a direct connection if the proxy is closed.

Guidance

  • Implement the proposed isProxyReachable() function to attempt a TCP connection to the proxy address, returning undefined if the connection fails.
  • Modify resolveProxyUri() to utilize the isProxyReachable() function, conditionally returning the proxy URI or undefined based on the proxy's reachability.
  • Consider handling potential exceptions or errors that may occur during the TCP connection attempt in isProxyReachable().
  • Test the modified resolveProxyUri() function with various proxy states (open and closed) to verify its correctness.

Example

function isProxyReachable(proxyAddress: string): boolean {
  const [host, port] = proxyAddress.split(':');
  const socket = require('net').createConnection({ host, port });
  return new Promise((resolve) => {
    socket.once('connect', () => {
      socket.destroy();
      resolve(true);
    });
    socket.once('error', () => {
      resolve(false);
    });
  });
}

function resolveProxyUri(proxyAddress: string): string | undefined {
  return isProxyReachable(proxyAddress).then((reachable) => {
    return reachable ? proxyAddress : undefined;
  });
}

Notes

The proposed solution assumes that the isProxyReachable() function will correctly determine the reachability of the proxy port. However, this approach may introduce additional latency due to the TCP connection attempt. Consider implementing a caching mechanism or a more efficient reachability check if performance becomes a concern.

Recommendation

Apply the proposed workaround by modifying the resolveProxyUri() function to check for proxy reachability, as this approach directly addresses the issue and provides a fallback for when the proxy is closed.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Feature]: Smart proxy detection - fallback to direct connection when proxy unavailable [1 participants]