Skip to content

Axios attempts to resolve IPv6 addresses as hostnames #5333

@Rishi556

Description

@Rishi556

Describe the bug

Up to v0.27.2, axios could be used to reach ipv6 endpoings with a format like the following: http://[2001:db8::5]:6001/lists. As of 1.0.0, axios thinks that's a hostname and attempts to use dns to resolve it.

  cause: Error: getaddrinfo ENOTFOUND [2001:db8::5]
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: '[2001:db8::5]'
  }
}

To Reproduce

Attempt to make a axios call to a ipv6 address using the common [IPv6]:PORT format.

Code snippet

let res = await axios.post('http://[2001:db8::5]:6001/lists', {})

Expected behavior

Axios should attempt to open a socket to 2001:db8::5 port 6001 and make the request.

Axios Version

1.2.0

Adapter Version

HTTP

Browser

No response

Browser Version

No response

Node.js Version

v18.12.0

OS

Mac 12.5.1

Additional Library Versions

No response

Additional context/Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions