Skip to content

ProxyAgent fails with IP-address HTTPS proxies on Node 26 #6144

Open

Description

@mathieudutour

Bug Description

Using an HTTPS proxy addressed by an IP literal causes ProxyAgent to pass that IP as the TLS servername. Node 26 rejects this before the TLS handshake:

ERR_INVALID_ARG_VALUE: The property 'options.servername' Setting the TLS ServerName to an IP address is not permitted.. Received '127.0.0.1'

Reproduction

Standalone reproduction script:

'use strict'

import { ProxyAgent, request } from "undici";

const dispatcher = new ProxyAgent("https://127.0.0.1:9");

try {
  await request("http://example.test/", { dispatcher });
} finally {
  await dispatcher.destroy();
}

A running proxy is unnecessary to trigger the error: the invalid SNI value is rejected before connection establishment. If the port is closed, the expected failure would be a connection error such as ECONNREFUSED.

Expected Behavior

For an IP-address HTTPS proxy, omit SNI while continuing to verify the proxy certificate against its IP address. DNS-addressed proxies should retain their hostname as SNI.

Environment

  • Node.js: v26.12.1
  • Undici: 8.12.3
  • macOS, arm64

Additional context

ProxyAgent supplies the proxy hostname as servername, including when it is an IP address. In lib/core/connect.js, explicitly supplied values bypass util.getServerName():

servername = servername || options.servername || util.getServerName(host) || null

Normalizing the selected value fixes the failure:

- servername = servername || options.servername || util.getServerName(host) || null
+ servername = util.getServerName(servername || options.servername || host) || null

Activity

  1. added
    bug
    on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions