{"record":{"id":"c635074a76abaded","repo":"jstedfast/MailKit","slug":"the-default-system-proxy-does-not-support-proxyuri-scheme","errorCode":null,"errorMessage":"The default system proxy does not support {proxyUri.Scheme}.","messagePattern":"The default system proxy does not support (.+?)\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Proxy/WebProxyClient.cs","lineNumber":129,"sourceCode":"\n\t\t\t\treturn new Socks4Client (proxyUri.Host, proxyUri.Port);\n\t\t\t}\n\n\t\t\tif (proxyUri.Scheme.Equals (\"socks4a\", StringComparison.OrdinalIgnoreCase)) {\n\t\t\t\tif (credential != null)\n\t\t\t\t\treturn new Socks4aClient (proxyUri.Host, proxyUri.Port, credential);\n\n\t\t\t\treturn new Socks4aClient (proxyUri.Host, proxyUri.Port);\n\t\t\t}\n\n\t\t\tif (proxyUri.Scheme.Equals (\"socks5\", StringComparison.OrdinalIgnoreCase)) {\n\t\t\t\tif (credential != null)\n\t\t\t\t\treturn new Socks5Client (proxyUri.Host, proxyUri.Port, credential);\n\n\t\t\t\treturn new Socks5Client (proxyUri.Host, proxyUri.Port);\n\t\t\t}\n\n\t\t\tthrow new NotSupportedException ($\"The default system proxy does not support {proxyUri.Scheme}.\");\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Connect to the target host.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// Connects to the target host and port through the proxy server.\n\t\t/// </remarks>\n\t\t/// <returns>The connected network stream.</returns>\n\t\t/// <param name=\"host\">The host name of the target server.</param>\n\t\t/// <param name=\"port\">The target server port.</param>\n\t\t/// <param name=\"cancellationToken\">The cancellation token.</param>\n\t\t/// <exception cref=\"System.ArgumentNullException\">\n\t\t/// <paramref name=\"host\"/> is <see langword=\"null\" />.\n\t\t/// </exception>\n\t\t/// <exception cref=\"System.ArgumentOutOfRangeException\">\n\t\t/// <paramref name=\"port\"/> is not between <c>0</c> and <c>65535</c>.\n\t\t/// </exception>","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Proxy/WebProxyClient.cs#L111-L147","documentation":"ProxyClient.GetProxyClient resolves the system default proxy (from system proxy settings / IWebProxy) and only knows how to build clients for socks4, socks4a and socks5 proxy URIs. When the system proxy URI uses any other scheme (http, https), it throws NotSupportedException because MailKit's default-proxy helper cannot create a client for it.","triggerScenarios":"Using ProxyClient.GetProxyClient with system proxy detection enabled while the OS/environment is configured with an HTTP or HTTPS proxy URL (e.g. http://proxy:8080 in HTTP_PROXY / Windows proxy settings).","commonSituations":"Corporate environments that publish HTTP proxies via environment variables or system settings; developers assuming MailKit can tunnel through an HTTP CONNECT proxy automatically.","solutions":["Change the system proxy setting to a socks5:// URI, or","Do not rely on the default system proxy: construct the appropriate client explicitly (e.g. Socks5Client) or use an HTTP-proxy-capable alternative (HttpProxyClient if available in your MailKit version).","Inspect the resolved proxyUri.Scheme before calling to know which scheme will be used."],"exampleFix":"// before\nvar client = ProxyClient.GetProxyClient(); // system proxy is http://proxy:8080\n// after\nvar client = new Socks5Client(\"proxy.corp.com\", 1080, credential); // explicit SOCKS5 proxy","handlingStrategy":"validation","validationCode":"var proxy = ProxyClient.GetDefaultProxy(); // or inspect system proxy\nif (proxy != null && !proxy.Uri.Scheme.StartsWith(\"socks\", StringComparison.OrdinalIgnoreCase))\n    throw new NotSupportedException($\"System proxy scheme '{proxy.Uri.Scheme}' is not supported; configure a socks5:// proxy or create the client manually\");","typeGuard":"bool IsSupportedProxyUri(Uri u) => u != null && (u.Scheme == \"socks4\" || u.Scheme == \"socks4a\" || u.Scheme == \"socks5\");","tryCatchPattern":"ProxyClient client;\ntry {\n    client = ProxyClient.GetProxyClient();\n} catch (NotSupportedException ex) {\n    // system proxy is http/https; fall back to explicit SOCKS5 client\n    client = new Socks5Client(\"proxy.corp.com\", 1080);\n}","preventionTips":["Set system/environment proxy URIs with a socks5:// scheme when using MailKit's default proxy helper","Prefer explicitly constructing the proxy client over system detection","Log the resolved proxy URI scheme during startup to catch this early"],"tags":["proxy","network","unsupported-scheme"],"backgroundTag":"unsupported-operation","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}