usebruno/bruno · error · Error

Invalid system https_proxy "${https_proxy}": ${error.message

Error message

Invalid system https_proxy "${https_proxy}": ${error.message}

What it means

Sibling of the http_proxy error: thrown when `proxyMode === 'system'` (no PAC URL) and `https_proxy` is non-empty, the request is HTTPS (`isHttpsRequest === true`), `shouldUseProxy` is true, and `new URL(https_proxy)` throws. Bruno will not create a `PatchedHttpsProxyAgent` from a value it cannot parse.

Source

Thrown at packages/bruno-electron/src/utils/proxy-util.js:206

            requestConfig.httpAgent = getOrCreateHttpAgent({ AgentClass: HttpProxyAgent, options: systemHttpProxyAgentOptions, proxyUri: http_proxy, timeline, disableCache, hostname });
          }
        } catch (error) {
          throw new Error(`Invalid system http_proxy "${http_proxy}": ${error.message}`);
        }
        try {
          if (https_proxy?.length && isHttpsRequest) {
            new URL(https_proxy);
            if (timeline) {
              timeline.push({
                timestamp: new Date(),
                type: 'info',
                message: `Using system proxy: ${https_proxy}`
              });
            }
            requestConfig.httpsAgent = getOrCreateHttpsAgent({ AgentClass: PatchedHttpsProxyAgent, options: tlsOptions, proxyUri: https_proxy, timeline, disableCache, hostname });
          }
        } catch (error) {
          throw new Error(`Invalid system https_proxy "${https_proxy}": ${error.message}`);
        }
      }
    }
  } else if (proxyMode === 'pac') {
    const pacSource = get(proxyConfig, 'pac.source');
    if (pacSource) {
      if (timeline) timeline.push({ timestamp: new Date(), type: 'info', message: `Resolving PAC: ${pacSource}` });
      try {
        const { directives, httpAgent, httpsAgent } = await resolveAgentsFromPac({ pacSource, requestUrl: requestConfig.url, requestProtocol: isHttpsRequest ? 'https' : 'http', tlsOptions, httpsAgentRequestFields, timeline, disableCache, hostname });
        if (httpAgent) requestConfig.httpAgent = httpAgent;
        if (httpsAgent) requestConfig.httpsAgent = httpsAgent;
        if (directives) {
          if (timeline) timeline.push({ timestamp: new Date(), type: 'info', message: `PAC directives: ${directives.join('; ')}` });
        } else {
          if (timeline) timeline.push({ timestamp: new Date(), type: 'info', message: 'PAC resolved: DIRECT (no proxy)' });
        }
      } catch (err) {
        if (timeline) timeline.push({ timestamp: new Date(), type: 'error', message: `PAC resolution failed: ${err.message}` });

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Add the scheme to the proxy URL: `https_proxy=http://proxy.local:3128` (the scheme describes the proxy endpoint, not the proxied traffic).
  2. Strip whitespace/quotes and confirm no unexpanded `${...}`.
  3. Add the target host to `no_proxy` if it should bypass the proxy.
  4. Restart Bruno so the electron main process reloads the env.

Example fix

// before
export https_proxy=proxy:3128   // new URL() throws

// after
export https_proxy=http://proxy.local:3128
Defensive patterns

Strategy: validation

Validate before calling

function isValidProxyUrl(value) {
  if (typeof value !== 'string' || value.trim() === '') return false;
  try { new URL(value.trim()); return true; } catch { return false; }
}
if (https_proxy && !isValidProxyUrl(https_proxy)) {
  throw new Error(`Refusing to start: https_proxy is malformed: ${https_proxy}`);
}

Type guard

function isHttpsProxyUrl(value: unknown): value is string {
  if (typeof value !== 'string' || value.trim() === '') return false;
  try { new URL(value.trim()); return true; } catch { return false; }
}

Try / catch

try {
  // build httpsAgent
} catch (error) {
  if (/Invalid system https_proxy/.test(error.message)) {
    // tell the user to fix https_proxy, optionally fall back to direct
  } else throw error;
}

Prevention

When it happens

Trigger: HTTPS request issued with a non-empty `proxyConfig.https_proxy`, no `pac_url`, `shouldUseProxy(url, no_proxy) === true`, and `new URL(https_proxy)` raising (invalid scheme, bad characters, empty host).

Common situations: Copied `https_proxy=proxy:3128` without scheme; value contains spaces or quotes from a `.env` file; proxy auto-config left a malformed token; an SSL-intercepting corporate proxy URL typed without `http://` (the proxy endpoint, not the target, usually needs `http://`).

Related errors


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