diff --git a/mongoose.c b/mongoose.c
index ab80a1f16454925c8286749b03e3ca9d4fb02ad9..44586e82406727734a79cf30a6b3e4faaaa88a85 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -2698,6 +2698,7 @@ void mg_send_digest_auth_request(struct mg_connection *c) {
             "realm=\"%s\", nonce=\"%lu\"\r\n\r\n",
             conn->server->config_options[AUTH_DOMAIN],
             (unsigned long) time(NULL));
+  close_local_endpoint(conn);
 }
 
 // Use the global passwords file, if specified by auth_gpass option,