diff --git a/lib/resty/http.lua b/lib/resty/http.lua
index a85f85a..9bcee1a 100644
--- a/lib/resty/http.lua
+++ b/lib/resty/http.lua
@@ -959,6 +959,7 @@ function _M.request_uri(self, uri, params)
     else
         local ok, err = self:set_keepalive(params.keepalive_timeout, params.keepalive_pool)
         if not ok then
+            self:close()
             ngx_log(ngx_ERR, err)
         end