SeleniumHQ/selenium · error · WebDriverException

Must provide either 'remote_server_addr' or 'client_config'

Error message

Must provide either 'remote_server_addr' or 'client_config'

What it means

Raised as WebDriverException by the RemoteConnection constructor when neither remote_server_addr nor client_config is provided. The connection needs at least one to know where the remote WebDriver server lives. If client_config is given it is used directly; if remote_server_addr is given a ClientConfig is derived from it; if neither is present the constructor cannot proceed.

Source

Thrown at py/selenium/webdriver/remote/remote_connection.py:328

        self,
        remote_server_addr: str | None = None,
        keep_alive: bool = True,
        ignore_proxy: bool = False,
        ignore_certificates: bool | None = False,
        init_args_for_pool_manager: dict | None = None,
        client_config: ClientConfig | None = None,
    ):
        if client_config:
            self._client_config = client_config
        elif remote_server_addr:
            self._client_config = ClientConfig(
                remote_server_addr=remote_server_addr,
                keep_alive=keep_alive,
                ignore_certificates=ignore_certificates,
                init_args_for_pool_manager=init_args_for_pool_manager,
            )
        else:
            raise WebDriverException("Must provide either 'remote_server_addr' or 'client_config'")

        # Keep backward compatibility for AppiumConnection - https://github.com/SeleniumHQ/selenium/issues/14694
        RemoteConnection._timeout = self._client_config.timeout
        RemoteConnection._ca_certs = self._client_config.ca_certs
        RemoteConnection._client_config = self._client_config
        RemoteConnection.extra_headers = self._client_config.extra_headers or RemoteConnection.extra_headers
        RemoteConnection.user_agent = self._client_config.user_agent or RemoteConnection.user_agent

        if remote_server_addr:
            warnings.warn(
                "setting remote_server_addr in RemoteConnection() is deprecated, set in client_config instead",
                DeprecationWarning,
                stacklevel=2,
            )

        if not keep_alive:
            warnings.warn(
                "setting keep_alive in RemoteConnection() is deprecated, set in client_config instead",

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Provide remote_server_addr: RemoteConnection('http://localhost:4444')
  2. Or provide a ClientConfig object: RemoteConnection(client_config=ClientConfig(remote_server_addr='http://localhost:4444'))
  3. Check that environment variables or config values feeding the URL are set before constructing the connection

Example fix

// before
conn = RemoteConnection()

// after
conn = RemoteConnection('http://localhost:4444')
# or
from selenium.webdriver.remote.client_config import ClientConfig
conn = RemoteConnection(client_config=ClientConfig(remote_server_addr='http://localhost:4444'))
Defensive patterns

Strategy: validation

Validate before calling

url = os.environ.get('REMOTE_URL')
if not url:
    raise ValueError('REMOTE_URL environment variable is not set')
conn = RemoteConnection(url)

Try / catch

try:
    conn = RemoteConnection(remote_url)
except WebDriverException:
    conn = RemoteConnection('http://localhost:4444')  # fallback to default

Prevention

When it happens

Trigger: Calling RemoteConnection() with no arguments, or passing both as None explicitly. Also when a caller constructs RemoteConnection with only optional kwargs that don't include either parameter.

Common situations: Refactoring code that previously had a default URL and removing it. Building RemoteConnection dynamically where the URL comes from an env var that is unset. Migration to ClientConfig API where the old remote_server_addr was removed without adding the new parameter.

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/70bee49d2b922575. Report an issue: GitHub.