diff --git a/Network.hs b/Network.hs
--- a/Network.hs
+++ b/Network.hs
@@ -222,11 +222,17 @@
 
 listen' serv = do
     proto <- getProtocolNumber "tcp"
+    -- We should probably specify addrFamily = AF_INET6 and the filter
+    -- code below should be removed. AI_ADDRCONFIG is probably not
+    -- necessary. But this code is well-tested. So, let's keep it.
     let hints = defaultHints { addrFlags = [AI_ADDRCONFIG, AI_PASSIVE]
                              , addrSocketType = Stream
                              , addrProtocol = proto }
     addrs <- getAddrInfo (Just hints) Nothing (Just serv)
-    let addr = head addrs
+    -- Choose an IPv6 socket if exists.  This ensures the socket can
+    -- handle both IPv4 and IPv6 if v6only is false.
+    let addrs' = filter (\x -> addrFamily x == AF_INET6) addrs
+        addr = if null addrs' then head addrs else head addrs'
     bracketOnError
         (socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr))
 	(sClose)
diff --git a/Network/Socket.hsc b/Network/Socket.hsc
--- a/Network/Socket.hsc
+++ b/Network/Socket.hsc
@@ -1042,7 +1042,7 @@
      return (pid, uid, gid)
 #endif
 
-##if !MIN_VERSION_base(4,3,1)
+##if !(MIN_VERSION_base(4,3,1))
 closeFdWith closer fd = closer fd
 ##endif
 
diff --git a/network.cabal b/network.cabal
--- a/network.cabal
+++ b/network.cabal
@@ -1,5 +1,5 @@
 name:           network
-version:        2.3.0.2
+version:        2.3.0.3
 license:        BSD3
 license-file:   LICENSE
 maintainer:     Johan Tibell <johan.tibell@gmail.com>
