{"record":{"id":"8d7eb06e0417e450","repo":"usebruno/bruno","slug":"proxy-protocol-and-hostname-are-required-when-prox","errorCode":null,"errorMessage":"Proxy protocol and hostname are required when proxy is enabled","messagePattern":"Proxy protocol and hostname are required when proxy is enabled","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-requests/src/utils/http-https-agents.ts","lineNumber":503,"sourceCode":"  let httpsAgent: HttpsAgent | HttpsProxyAgent<any> | SocksProxyAgent | undefined;\n\n  // Determine if this is an HTTPS request\n  const isHttpsRequest = requestUrl ? requestUrl.startsWith('https:') : true;\n\n  // Extract hostname for per-host agent caching (enables TLS session reuse per host)\n  const hostname = extractHostname(requestUrl);\n\n  if (proxyMode === 'on') {\n    const shouldProxy = shouldUseProxy(requestUrl, get(proxyConfig, 'bypassProxy', ''));\n    if (shouldProxy) {\n      const proxyProtocol = get(proxyConfig, 'protocol');\n      const proxyHostname = get(proxyConfig, 'hostname');\n      const proxyPort = get(proxyConfig, 'port');\n      const proxyAuthEnabled = !get(proxyConfig, 'auth.disabled', false);\n      const socksEnabled = proxyProtocol && proxyProtocol.includes('socks');\n\n      if (!proxyProtocol || !proxyHostname) {\n        throw new Error('Proxy protocol and hostname are required when proxy is enabled');\n      }\n\n      const uriPort = isUndefined(proxyPort) || isNull(proxyPort) ? '' : `:${proxyPort}`;\n      let proxyUri: string;\n      if (proxyAuthEnabled) {\n        const proxyAuthUsername = encodeURIComponent(get(proxyConfig, 'auth.username', ''));\n        const proxyAuthPassword = encodeURIComponent(get(proxyConfig, 'auth.password', ''));\n        proxyUri = `${proxyProtocol}://${proxyAuthUsername}:${proxyAuthPassword}@${proxyHostname}${uriPort}`;\n      } else {\n        proxyUri = `${proxyProtocol}://${proxyHostname}${uriPort}`;\n      }\n\n      // When the proxy itself uses HTTPS, the agent connecting to it needs TLS options\n      // (e.g., ca certs) even for plain HTTP requests\n      const isHttpsProxy = proxyProtocol === 'https';\n      const httpProxyAgentOptions = isHttpsProxy ? { keepAlive: true, ...tlsOptions } : { keepAlive: true };\n\n      // Only set the agent needed for the request protocol","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-requests/src/utils/http-https-agents.ts#L485-L521","documentation":"When proxyMode is 'on' and the URL is not bypassed, the loader requires both protocol and hostname in the proxy config; a falsy value for either throws before constructing the proxy URI. Prevents producing a malformed proxy URL like '://:0'.","triggerScenarios":"Proxy enabled (proxyMode='on'), shouldUseProxy returned true for the URL, but proxyConfig.protocol and/or proxyConfig.hostname are empty/undefined.","commonSituations":"User toggled proxy on but left host/protocol blank; partial proxy config saved; collection-level proxy overrode app-level with an empty object; protocol field renamed in a settings migration.","solutions":["In Preferences/Collection proxy settings, set both protocol (http/https/socks4/socks5) and hostname.","If you do not actually need a proxy, switch proxyMode to 'off' or 'system'.","Add the URL to bypassProxy if this host should skip the proxy."],"exampleFix":"// before\n{ proxyMode:'on', proxyConfig:{ protocol:'', hostname:'', port:8080 } }\n\n// after\n{ proxyMode:'on', proxyConfig:{ protocol:'http', hostname:'proxy.corp', port:8080 } }","handlingStrategy":"validation","validationCode":"if (proxyMode === 'on') {\n  const protocol = get(proxyConfig,'protocol'), hostname = get(proxyConfig,'hostname');\n  if (!protocol || !hostname) throw new Error('Proxy protocol and hostname are required when proxy is enabled');\n}","typeGuard":"function isValidManualProxy(c): boolean { return !!c && typeof c.protocol==='string' && !!c.protocol && typeof c.hostname==='string' && !!c.hostname; }","tryCatchPattern":null,"preventionTips":["Validate proxy protocol+hostname before enabling proxyMode 'on'.","Add specific hosts to bypassProxy instead of leaving protocol/hostname blank."],"tags":["proxy","validation","config"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}