{"record":{"id":"82e9d2df9249dd19","repo":"composer/composer","slug":"unable-to-find-proxy-host-in-envname","errorCode":null,"errorMessage":"unable to find proxy host in {$envName}","messagePattern":"unable to find proxy host in (.+?)","errorType":"validation","errorClass":"\\RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Composer/Util/Http/ProxyItem.php","lineNumber":48,"sourceCode":"    private $optionsAuth;\n\n    /**\n     * @param string $proxyUrl The value from the environment\n     * @param string $envName The name of the environment variable\n     * @throws \\RuntimeException If the proxy url is invalid\n     */\n    public function __construct(string $proxyUrl, string $envName)\n    {\n        $syntaxError = sprintf('unsupported `%s` syntax', $envName);\n\n        if (strpbrk($proxyUrl, \"\\r\\n\\t\") !== false) {\n            throw new \\RuntimeException($syntaxError);\n        }\n        if (false === ($proxy = parse_url($proxyUrl))) {\n            throw new \\RuntimeException($syntaxError);\n        }\n        if (!isset($proxy['host'])) {\n            throw new \\RuntimeException('unable to find proxy host in ' . $envName);\n        }\n\n        $scheme = isset($proxy['scheme']) ? strtolower($proxy['scheme']) . '://' : 'http://';\n        $safe = '';\n\n        if (isset($proxy['user'])) {\n            $safe = '***';\n            $user = $proxy['user'];\n            $auth = rawurldecode($proxy['user']);\n\n            if (isset($proxy['pass'])) {\n                $safe .= ':***';\n                $user .= ':' . $proxy['pass'];\n                $auth .= ':' . rawurldecode($proxy['pass']);\n            }\n\n            $safe .= '@';\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/composer/composer/blob/c435d285c9120efdca35696769c72ea9fdcc0466/src/Composer/Util/Http/ProxyItem.php#L30-L66","documentation":"The proxy URL parsed via parse_url but produced no `host` component, so Composer cannot route traffic. Reported at src/Composer/Util/Http/ProxyItem.php:48 as 'unable to find proxy host in <envName>'.","triggerScenarios":"Values like `http://:8080`, `http:///path`, or a bare scheme `http://` — parse_url succeeds but $proxy['host'] is unset (line 47).","commonSituations":"Misformatted proxy strings missing the hostname; port-only values; proxy set to a bare scheme by mistake.","solutions":["Add the host: `http://proxy.example.com:8080`.","If using a Unix-socket proxy, switch to a supported TCP host (Composer/curl need a hostname).","Clear the env var if it was set unintentionally."],"exampleFix":"# before\nHTTPS_PROXY=\"http://:3128\"\n\n# after\nHTTPS_PROXY=\"http://squid.example.com:3128\"","handlingStrategy":"validation","validationCode":"$p = parse_url(getenv('HTTPS_PROXY') ?: '');\nif (is_array($p) && !isset($p['host'])) {\n    throw new \\InvalidArgumentException('HTTPS_PROXY has no host.');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $proxy = new \\Composer\\Util\\Http\\ProxyItem($val, 'HTTPS_PROXY');\n} catch (\\RuntimeException $e) {\n    if (str_starts_with($e->getMessage(), 'unable to find proxy host in')) {\n        // fix the URL to include a host, then retry\n    }\n    throw $e;\n}","preventionTips":["Always include a hostname in proxy URLs.","Validate the parsed host before Composer runs."],"tags":["proxy","environment","config","host"],"backgroundTag":null,"analyzedSha":"c435d285c9120efdca35696769c72ea9fdcc0466","analyzedAt":"2026-08-07T18:58:23.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}