microsoft/playwright · error · Error

Socks4 proxy protocol does not support authentication

Error message

Socks4 proxy protocol does not support authentication

What it means

Thrown by normalizeProxySettings() after it parses the proxy.server URL. SOCKS4 has no authentication mechanism in the protocol, so when the server URL resolves to protocol 'socks4:' and username or password is set, Playwright rejects the configuration rather than silently ignoring the credentials.

Source

Thrown at packages/playwright-core/src/server/browserContext.ts:826

      throw new Error('pfx is specified together with cert, key or passphrase');
  }
}

export function normalizeProxySettings(proxy: types.ProxySettings): types.ProxySettings {
  let { server, bypass } = proxy;
  let url;
  try {
    // new URL('127.0.0.1:8080') throws
    // new URL('localhost:8080') fails to parse host or protocol
    // In both of these cases, we need to try re-parse URL with `http://` prefix.
    url = new URL(server);
    if (!url.host || !url.protocol)
      url = new URL('http://' + server);
  } catch (e) {
    url = new URL('http://' + server);
  }
  if (url.protocol === 'socks4:' && (proxy.username || proxy.password))
    throw new Error(`Socks4 proxy protocol does not support authentication`);
  if (url.protocol === 'socks5:' && (proxy.username || proxy.password))
    throw new Error(`Browser does not support socks5 proxy authentication`);
  server = url.protocol + '//' + url.host;
  if (bypass)
    bypass = bypass.split(',').map(t => t.trim()).join(',');
  return { ...proxy, server, bypass };
}

const paramsThatAllowContextReuse: (keyof channels.BrowserNewContextForReuseParams)[] = [
  'colorScheme',
  'forcedColors',
  'reducedMotion',
  'contrast',
  'screen',
  'userAgent',
  'viewport',
  'testIdAttributeName',
];

View on GitHub (pinned to c8fc3bf8d3)

Solutions

  1. Remove username/password from the proxy config if the SOCKS4 proxy truly needs none.
  2. Switch server to an HTTP/HTTPS proxy that supports Basic auth, e.g. proxy: { server: 'http://host:8080', username, password }.
  3. Run an authenticated upstream tunnel (e.g. ssh -D) locally and point Playwright at the unauthenticated local SOCKS endpoint.

Example fix

// before
proxy: { server: 'socks4://proxy:1080', username: 'u', password: 'p' }
// after
proxy: { server: 'socks4://proxy:1080' } // no auth
Defensive patterns

Strategy: validation

Validate before calling

function validateProxy(proxy?: { server: string; username?: string; password?: string }) {
  if (!proxy) return;
  const proto = new URL(proxy.server).protocol;
  if (proto === 'socks4:' && (proxy.username || proxy.password))
    throw new Error('SOCKS4 cannot carry auth; remove credentials or switch proxy type');
}

Type guard

function isAuthFreeSocks4(proxy: { server: string; username?: string; password?: string }): boolean {
  return new URL(proxy.server).protocol !== 'socks4:' || (!proxy.username && !proxy.password);
}

Prevention

When it happens

Trigger: Launch/newContext with proxy: { server: 'socks4://host:1080', username: 'u', password: 'p' }. Also reached via launchOptions.proxy or the socksProxyPort-derived socks5 (that one hits 225).

Common situations: Corporate SOCKS proxy that requires auth but was configured as socks4. Mistyping socks5 as socks4. Using a SOCKS proxy URL with embedded credentials.

Understand the failure class

Related errors


AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12). Data as JSON: /api/errors/b061eb40cdb7d635. Report an issue: GitHub.