denoland/deno · error · TypeError
The url passed into 'proxy.url' has an invalid scheme for…
Error message
The url passed into 'proxy.url' has an invalid scheme for this transport.
What it means
Thrown in createHttpClient() (ext/fetch/22_http_client.js) when the proxy configuration declares a transport but proxy.url's scheme belongs to a different transport: for transport "http", urls starting with https:, socks5:, or socks5h: are rejected (and symmetrically for "https", http:/socks urls). This validates scheme-vs-transport consistency before the client is built.
Solutions
- Align them: `proxy: { url: "https://proxy.example:3128", transport: "https" }` for TLS proxies.
- Or omit transport and let Deno infer it from the scheme: `proxy: { url: "http://proxy.example:3128" }`.
- For SOCKS proxies use transport "socks5"/"socks5h" with a matching socks5:// url.
Example fix
// before
const client = Deno.createHttpClient({
proxy: { url: "https://proxy.internal:3128", transport: "http" }, // mismatch
});
// after
const client = Deno.createHttpClient({
proxy: { url: "https://proxy.internal:3128", transport: "https" },
}); Defensive patterns
Strategy: validation
Validate before calling
const scheme = new URL(proxyUrl).protocol; // "https:", "socks5:", ...
const transport = scheme.replace(":", "").replace("socks5h", "socks5h");
const client = Deno.createHttpClient({ proxy: { url: proxyUrl, transport } }); // or omit transport entirely Try / catch
try { Deno.createHttpClient(opts); } catch (e) { if (e instanceof TypeError && e.message.includes("invalid scheme for this transport")) { delete opts.proxy.transport; /* let Deno infer from scheme */ client = Deno.createHttpClient(opts); } else throw e; } Prevention
- Derive transport from the URL scheme instead of hardcoding both.
- Or specify only proxy.url and let the runtime infer.
- Validate proxy config once at startup so bad URLs fail before the first fetch.
When it happens
Trigger: `Deno.createHttpClient({ proxy: { url: "https://proxy.example:3128", transport: "http" } })`; also `proxy: { url: "socks5://h:1080", transport: "http" }`. The string transport form `proxy: { url }` (no transport field) infers from the scheme and does not hit this check.
Common situations: Config files where url and transport drift apart after edits (TLS added to proxy but transport left "http"); copying an HTTPS proxy URL into a template that hardcodes transport "http"; CI environments injecting a corporate HTTPS proxy while code pins transport.
Related errors
- Invalid value for 'proxy.transport' option
- fetch failed
- Return value from serve handler must not be an error…
- Bad cluster.schedulingPolicy
- Blob URL fetch only supports GET method
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/e2f143cd9e6b80bc.
Report an issue: GitHub.
Appendix: source
Thrown at ext/fetch/22_http_client.js:42
// Don't mutate the caller's options object. Historically `caCerts` and
// `proxy.transport` were written back onto whatever the user passed in,
// which broke reuse of a single options object across multiple calls
// (denoland/deno#29347).
options = ObjectAssign({ __proto__: null }, options);
options.caCerts = options.caCerts ?? [];
if (options.proxy) {
const proxy = ObjectAssign({ __proto__: null }, options.proxy);
options.proxy = proxy;
if (ObjectHasOwn(proxy, "transport")) {
switch (proxy.transport) {
case "http": {
const url = proxy.url;
if (
StringPrototypeStartsWith(url, "https:") ||
StringPrototypeStartsWith(url, "socks5:") ||
StringPrototypeStartsWith(url, "socks5h:")
) {
throw new TypeError(
`The url passed into 'proxy.url' has an invalid scheme for this transport.`,
);
}
proxy.transport = "http";
break;
}
case "https": {
const url = proxy.url;
if (
StringPrototypeStartsWith(url, "http:") ||
StringPrototypeStartsWith(url, "socks5:") ||
StringPrototypeStartsWith(url, "socks5h:")
) {
throw new TypeError(
`The url passed into 'proxy.url' has an invalid scheme for this transport.`,
);
}
proxy.transport = "http";View on GitHub (pinned to 9ad36f7a2c)