diff --git a/CHANGELOG b/CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,9 @@
 # Changelog for Hedis
 
+## 0.9.9
+
+* PR #90. set SO_KEEPALIVE option on underlying connection socket 
+
 ## 0.9.8
 
 * Fix syntax errors from redis when using scanOpts to specify match
diff --git a/hedis.cabal b/hedis.cabal
--- a/hedis.cabal
+++ b/hedis.cabal
@@ -1,5 +1,5 @@
 name:               hedis
-version:            0.9.8
+version:            0.9.9
 synopsis:
     Client library for the Redis datastore: supports full command set,
     pipelining.
diff --git a/src/Database/Redis/ProtocolPipelining.hs b/src/Database/Redis/ProtocolPipelining.hs
--- a/src/Database/Redis/ProtocolPipelining.hs
+++ b/src/Database/Redis/ProtocolPipelining.hs
@@ -28,6 +28,8 @@
 import           Data.IORef
 import           Data.Typeable
 import           Network
+import qualified Network.BSD as BSD
+import qualified Network.Socket as NS
 import           System.IO
 import           System.IO.Error
 import           System.IO.Unsafe
@@ -53,8 +55,8 @@
 instance Exception ConnectionLostException
 
 connect :: HostName -> PortID -> IO Connection
-connect host port =
-  bracketOnError (connectTo host port) hClose $ \connHandle -> do
+connect hostName (PortNumber port) =
+  bracketOnError hConnect hClose $ \connHandle -> do
     hSetBinaryMode connHandle True
     connReplies <- newIORef []
     connPending <- newIORef []
@@ -64,6 +66,15 @@
     writeIORef connReplies rs
     writeIORef connPending rs
     return conn
+  where hConnect =
+          bracketOnError mkSocket NS.close $ \sock -> do
+          NS.setSocketOption sock NS.KeepAlive 1
+          host <- BSD.getHostByName hostName
+          NS.connect sock $ NS.SockAddrInet port (BSD.hostAddress host)
+          NS.socketToHandle sock ReadWriteMode
+        mkSocket = NS.socket NS.AF_INET NS.Stream 0
+connect hostName portID =
+  error $ "Connection to " ++ hostName ++ ":" ++ show portID ++ " not supported"
 
 disconnect :: Connection -> IO ()
 disconnect Conn{..} = do
