diff --git a/changelog b/changelog
index b2f4a2159ba0e21a5426e29c1568bccb3892ac16..200e542aee16a93b0470665b2af75217c3512f3d 100644
--- a/changelog
+++ b/changelog
@@ -1,6 +1,14 @@
 Changelog
 ---------
 
+(since last tag)
+
+User api changes
+----------------
+
+LWS_CALLBACK_CLIENT_CONNECTION_ERROR may provide an error string if in is
+non-NULL.  If so, the string has length len.
+
 v1.4-chrome43-firefox36
 =======================
 
diff --git a/lib/client.c b/lib/client.c
index fd65ae8e8d839fd34eab09bc51031f8255b6d799..ebf6403921cbcc6db874d88143f71be0404175ec 100644
--- a/lib/client.c
+++ b/lib/client.c
@@ -481,6 +481,7 @@ lws_client_interpret_server_handshake(struct libwebsocket_context *context,
 	int okay = 0;
 	char *p;
 	int len;
+	int isErrorCodeReceived = 0;
 #ifndef LWS_NO_EXTENSIONS
 	char ext_name[128];
 	struct libwebsocket_extension *ext;
@@ -498,6 +499,8 @@ lws_client_interpret_server_handshake(struct libwebsocket_context *context,
 
 	if (lws_hdr_total_length(wsi, WSI_TOKEN_ACCEPT) == 0) {
 		lwsl_info("no ACCEPT\n");
+		p = lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP);
+		isErrorCodeReceived = 1;
 		goto bail3;
 	}
 
@@ -786,10 +789,17 @@ bail3:
 	close_reason = LWS_CLOSE_STATUS_NOSTATUS;
 
 bail2:
-	if (wsi->protocol)
-		wsi->protocol->callback(context, wsi,
-			LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
-						      wsi->user_space, NULL, 0);
+	if (wsi->protocol) {
+		if (isErrorCodeReceived && p) {
+			wsi->protocol->callback(context, wsi,
+				LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
+					wsi->user_space, p, (unsigned int)strlen(p));
+		} else {
+			wsi->protocol->callback(context, wsi,
+				LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
+							      wsi->user_space, NULL, 0);
+		}
+	}
 
 	lwsl_info("closing connection due to bail2 connection error\n");
 
diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h
index ccbcbf1bdcdae1f730ae0e2f69998965e0b9355b..7f4bea327ef85238f3f58b5da4ac08d0f2f0b904 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -587,7 +587,9 @@ struct libwebsocket_extension;
  *				an incoming client
  *
  *  LWS_CALLBACK_CLIENT_CONNECTION_ERROR: the request client connection has
- *        been unable to complete a handshake with the remote server
+ *        been unable to complete a handshake with the remote server.  If
+ *	  in is non-NULL, you can find an error string of length len where
+ *	  it points to.
  *
  *  LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH: this is the last chance for the
  *				client user code to examine the http headers