Skip to content

Gitlab::HTTP prefers IPv6 when making connections to localhost

In the UrlBlocker class, the HTTP clients within the project defer to the first IP address that is returned from hostname resolution.

In the case of localhost, this is an IPv6 address - which causes issues with not being able to resolve services that are only listening on an IPv4 address. Outgoing connections to a server listening on localhost (IPv4) will currently fail, where a vanilla RestClient/Net::HTTP client will be able to make the request.

One use case is Docker services that are listening on localhost:

  • the ability to listen for IPv6 connections in docker must be configured in the daemon, and not at runtime.
  • IPv6 networking is not supported in Docker for Mac or Windows.

Suggestion: Make GitLab::HTTP resolve the hostname to whichever one it can open a connection to.

Edited by Sean Gregory