SeleniumHQ/selenium · error · ValueError
Specified proxy type ({compatible_proxy}) not compatible wit
Error message
Specified proxy type ({compatible_proxy}) not compatible with current setting ({self.proxyType}) What it means
A Proxy enforces that proxy settings stay self-consistent: each connection-related property (http_proxy, ssl_proxy, socks_*, no_proxy) is bound to a specific ProxyType (MANUAL or PAC). _verify_proxy_type_compatibility raises ValueError if the current proxyType is neither UNSPECIFIED nor the type that property requires. E.g. setting http_proxy while proxyType is PAC is rejected.
Source
Thrown at py/selenium/webdriver/common/proxy.py:164
@property
def proxy_type(self):
"""Returns proxy type as `ProxyType`."""
return self.proxyType
@proxy_type.setter
def proxy_type(self, value) -> None:
"""Sets proxy type.
Args:
value: The proxy type.
"""
self._verify_proxy_type_compatibility(value)
self.proxyType = value
def _verify_proxy_type_compatibility(self, compatible_proxy):
if self.proxyType not in (ProxyType.UNSPECIFIED, compatible_proxy):
raise ValueError(
f"Specified proxy type ({compatible_proxy}) not compatible with current setting ({self.proxyType})"
)
def to_capabilities(self):
proxy_caps = {"proxyType": self.proxyType["string"].lower()}
proxies = [
"autodetect",
"httpProxy",
"proxyAutoconfigUrl",
"sslProxy",
"noProxy",
"socksProxy",
"socksUsername",
"socksPassword",
"socksVersion",
]
for proxy in proxies:
attr_value = getattr(self, proxy)View on GitHub (pinned to aa36b38e69)
Solutions
- Set proxy_type = ProxyType.MANUAL before assigning http/ssl/socks/no_proxy properties.
- For PAC, set proxy_autoconfig_url and proxy_type = ProxyType.PAC; do not set manual hosts.
- If reusing a Proxy, reset proxy_type to UNSPECIFIED before reconfiguring.
Example fix
# before proxy.proxy_type = ProxyType.PAC proxy.http_proxy = 'localhost:8080' # PAC != MANUAL -> ValueError # after proxy.proxy_type = ProxyType.MANUAL proxy.http_proxy = 'localhost:8080' # or for PAC proxy.proxy_type = ProxyType.PAC proxy.proxy_autoconfig_url = 'http://host/proxy.pac'
Defensive patterns
Strategy: validation
Validate before calling
from selenium.webdriver.common.proxy import ProxyType
# Ensure MANUAL before setting host-type properties
if proxy.proxyType not in (ProxyType.UNSPECIFIED, ProxyType.MANUAL):
proxy.proxy_type = ProxyType.MANUAL
proxy.http_proxy = 'localhost:8080' Try / catch
try:
proxy.http_proxy = host
except ValueError:
proxy.proxy_type = ProxyType.MANUAL
proxy.http_proxy = host Prevention
- Set the proxy type (MANUAL/PAC) before configuring host details.
- Reset proxy_type to UNSPECIFIED when reusing a Proxy object.
- Do not mix MANUAL hosts with PAC configuration.
When it happens
Trigger: Setting proxy.http_proxy = 'host' when proxyType is already PAC or AUTODETECT. Setting proxy.socks_proxy after setting proxyType = PAC. The order of assignment matters: once proxyType is committed to a non-MANUAL type, MANUAL-bound properties fail.
Common situations: Setting the proxy type first to the wrong value, then trying to add host details. Reusing a Proxy object across configurations. Mixing PAC and manual host settings.
Related errors
- No proxy type is found for {value}
- unknown option#{'s' if not_allowed.size != 1}: #{not_allowed
- invalid proxy type: #{type.inspect}, expected one of #{TYPES
- Unexpected compiled output format. Expected it to start with
- Unexpected compiled output format. Expected it to start with
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/c10d75b9600cc466.
Report an issue: GitHub.