         |> Map.put(:tls_opts, tls_opts)
         |> Map.put(:tcp_opts, tcp_opts)
 
-      {_type, host} = format_host(uri.host)
+      {_type, host} = domain_or_ip(uri.host)
 
       with {:ok, pid} <- :gun.open(host, uri.port, opts_with_master_keys) do
         {:ok, pid}

      tls_opts =
        with "https" <- uri.scheme,
             true <- opts[:certificates_verification] do
          formatted_host =
            case format_host(uri.host) do
              {:domain, domain} -> domain
              {:ip, _} -> to_charlist(uri.host)
            end

          security_opts = [
            verify: :verify_peer,
            cacertfile: CAStore.file_path(),
            depth: 20,
            reuse_sessions: false,
            verify_fun: {&:ssl_verify_hostname.verify_fun/3, [check_hostname: formatted_host]}
          ]

          Keyword.merge(security_opts, tls_opts)

    end

    defp tunnel_opts(uri) do
      {_type, host} = domain_or_ip(uri.host)
      %{host: host, port: uri.port}
    end

