diff --git a/lib/url.c b/lib/url.c
index 4281109a6bf887800bfaee9f5adc475eebf39cb8..9318d4132b2a7868c80ee32b98e48b28cb863466 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1561,7 +1561,7 @@ static CURLcode _connect(CURL *curl,
     if(!conn->hp) {
 #ifdef ENABLE_IPV6
       /* it might already be set if reusing a connection */
-      conn->hp = Curl_getaddrinfo(data, conn->name, data->port);
+      conn->hp = Curl_getaddrinfo(data, conn->name, conn->port);
 #else
       /* it might already be set if reusing a connection */
       conn->hp = Curl_gethost(data, conn->name, &conn->hostent_buf);