diff --git a/src/ChangeLog b/src/ChangeLog
index 18dfa9b5..a7c739ca 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2005-06-17  Hrvoje Niksic  <hniksic@xemacs.org>
+
+	* connect.c (socket_has_inet6): Removed.
+
+	* host.c (lookup_host): Don't use the AI_ADDRCONFIG getaddrinfo
+	hint.
+
 2005-06-16  Hrvoje Niksic  <hniksic@xemacs.org>
 
 	* init.c (cmd_lockable_boolean): Improve the error message so it
diff --git a/src/connect.c b/src/connect.c
index 24dd1faa..16b6de6c 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -608,37 +608,6 @@ retryable_socket_connect_error (int err)
   return 1;
 }
 
-#ifdef ENABLE_IPV6
-# ifndef HAVE_GETADDRINFO_AI_ADDRCONFIG
-
-/* Return non-zero if the INET6 socket family is supported on the
-   system.
-
-   This doesn't guarantee that we're able to connect to IPv6 hosts,
-   but it's better than nothing.  It is only used on systems where
-   getaddrinfo doesn't support AI_ADDRCONFIG.  (See lookup_host.)  */
-
-int
-socket_has_inet6 (void)
-{
-  static int supported = -1;
-  if (supported == -1)
-    {
-      int sock = socket (AF_INET6, SOCK_STREAM, 0);
-      if (sock < 0)
-	supported = 0;
-      else
-	{
-	  fd_close (sock);
-	  supported = 1;
-	}
-    }
-  return supported;
-}
-
-# endif/* not HAVE_GETADDRINFO_AI_ADDRCONFIG */
-#endif /* ENABLE_IPV6 */
-
 /* Wait for a single descriptor to become available, timing out after
    MAXTIME seconds.  Returns 1 if FD is available, 0 for timeout and
    -1 for error.  The argument WAIT_FOR can be a combination of
diff --git a/src/connect.h b/src/connect.h
index 85242260..4dbebad7 100644
--- a/src/connect.h
+++ b/src/connect.h
@@ -59,7 +59,6 @@ enum {
 };
 int select_fd PARAMS ((int, double, int));
 int test_socket_open PARAMS ((int));
-int socket_has_inet6 PARAMS ((void));
 
 typedef int (*fd_reader_t) PARAMS ((int, char *, int, void *));
 typedef int (*fd_writer_t) PARAMS ((int, char *, int, void *));
diff --git a/src/host.c b/src/host.c
index f1fb64e7..af736dab 100644
--- a/src/host.c
+++ b/src/host.c
@@ -767,17 +767,11 @@ lookup_host (const char *host, int flags)
     else if (opt.ipv6_only)
       hints.ai_family = AF_INET6;
     else
-      {
+      /* We used to specify AI_ADDRCONFIG here, but removed it because
+	 it fails in on systems with IPv6 loopbacks, it loses on AIX
+	 5.1, and isn't really needed as we sort the addresses).  */
 	hints.ai_family = AF_UNSPEC;
-#ifdef AI_ADDRCONFIG
-	hints.ai_flags |= AI_ADDRCONFIG;
-#else
-	/* On systems without AI_ADDRCONFIG, emulate it by manually
-	   checking whether the system supports IPv6 sockets.  */
-	if (!socket_has_inet6 ())
-	  hints.ai_family = AF_INET;
-#endif
-      }
+
     if (flags & LH_BIND)
       hints.ai_flags |= AI_PASSIVE;