usebruno/bruno · error · Error

Invalid system https_proxy

Error message

Invalid system https_proxy

What it means

Thrown by getHttpHttpsAgents when proxyMode is 'system', the request is HTTPS, a non-empty https_proxy value is present, and either new URL(https_proxy) or getOrCreateHttpsAgent(PatchedHttpsProxyAgent, ...) raises. The library refuses to silently fall back to a direct connection because doing so would bypass the user's intended (and now broken) proxy, leaking traffic. The catch discards the original error's specifics, surfacing only this generic message.

Source

Thrown at packages/bruno-requests/src/utils/http-https-agents.ts:580

      const shouldUseSystemProxy = shouldUseProxy(requestUrl, no_proxy || '');
      if (shouldUseSystemProxy) {
        try {
          if (http_proxy?.length && !isHttpsRequest) {
            const parsedHttpProxy = new URL(http_proxy);
            const isHttpsSystemProxy = parsedHttpProxy.protocol === 'https:';
            const systemHttpProxyAgentOptions = isHttpsSystemProxy ? { keepAlive: true, ...tlsOptions } : { keepAlive: true };
            httpAgent = getOrCreateHttpAgent({ AgentClass: HttpProxyAgent, options: systemHttpProxyAgentOptions as any, proxyUri: http_proxy, timeline: timeline || null, disableCache, hostname });
          }
        } catch (error) {
          throw new Error('Invalid system http_proxy');
        }
        try {
          if (https_proxy?.length && isHttpsRequest) {
            new URL(https_proxy);
            httpsAgent = getOrCreateHttpsAgent({ AgentClass: PatchedHttpsProxyAgent, options: tlsOptions as any, proxyUri: https_proxy, timeline: timeline || null, disableCache, hostname }) as HttpsAgent;
          }
        } catch (error) {
          throw new Error('Invalid system https_proxy');
        }
      }
    }
  }

  if (!httpAgent && !httpsAgent) {
    if (isHttpsRequest) {
      httpsAgent = getOrCreateHttpsAgent({ AgentClass: https.Agent, options: tlsOptions as any, timeline: timeline || null, disableCache, hostname }) as HttpsAgent;
    } else {
      httpAgent = getOrCreateHttpAgent({ AgentClass: http.Agent, options: { keepAlive: true }, timeline: timeline || null, disableCache, hostname });
    }
  }

  return { httpAgent, httpsAgent };
}

const getHttpHttpsAgents = async ({
  requestUrl,

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Inspect the effective https_proxy value (systemProxyConfig.get('https_proxy')) and confirm it parses: must include a scheme (http:// or https://), a host, and a port, e.g. http://proxy.corp:3128.
  2. If a SOCKS proxy is required, switch the collection's proxy mode to a configured proxy that uses a SOCKS-capable agent rather than 'system'; the HttpsProxyAgent path does not support socks://.
  3. Temporarily set proxyMode to 'off' or a working 'configured' proxy to confirm the https_proxy value is the culprit, then correct it.
  4. Ensure no_proxy still matches the request URL if the target should bypass the proxy entirely.

Example fix

// before
process.env.https_proxy = 'proxy.corp:3128'; // missing scheme -> new URL() throws

// after
process.env.https_proxy = 'http://proxy.corp:3128';
Defensive patterns

Strategy: validation

Validate before calling

import { URL } from 'node:url';
function assertValidProxy(value, label) {
  if (!value) return; // empty is allowed (means 'no proxy')
  let u;
  try { u = new URL(value); } catch { throw new Error(`${label} is not a valid URL: ${value}`); }
  if (!['http:', 'https:'].includes(u.protocol)) {
    throw new Error(`${label} must be http(s):// scheme, got ${u.protocol}`);
  }
  if (!u.hostname) throw new Error(`${label} is missing a host`);
}
// run before issuing requests
assertValidProxy(systemProxyConfig.get('https_proxy'), 'https_proxy');
assertValidProxy(systemProxyConfig.get('http_proxy'), 'http_proxy');

Type guard

import { URL } from 'node:url';
function isValidProxyUrl(v) {
  if (typeof v !== 'string' || v.length === 0) return false;
  try {
    const u = new URL(v);
    return ['http:', 'https:'].includes(u.protocol) && !!u.hostname;
  } catch {
    return false;
  }
}

Try / catch

try {
  const { httpAgent, httpsAgent } = await getHttpHttpsAgents(opts);
} catch (e) {
  if (/Invalid system https?_proxy/.test(e?.message)) {
    // surface a precise, actionable message to the user; do not silently fall back
    throw new Error('Configured proxy is invalid. Fix or disable it. Cause: ' + e.message);
  }
  throw e;
}

Prevention

When it happens

Trigger: An HTTPS request runs with proxyMode 'system'; shouldUseProxy(requestUrl, no_proxy) returns true; https_proxy env/collection value is non-empty but malformed (e.g. 'localhost:3128' with no scheme, 'htps://...', 'ftp://proxy', trailing stray chars), OR it is well-formed but PatchedHttpsProxyAgent construction fails (unsupported scheme, missing host, bad TLS options).

Common situations: Corporate proxy env vars copied without an http:// scheme; switching from HTTP to SOCKS proxy (this agent only handles HTTP/HTTPS CONNECT proxies); typo in the collection's system-proxy override; proxy value containing auth with unescaped special characters; recent OS-level proxy change propagated into the systemProxyConfig.

Related errors


AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13). Data as JSON: /api/errors/502e35e46d589fae. Report an issue: GitHub.