diff --git a/mongoose.c b/mongoose.c
index 75ee3ac70e99fdea14f7962fdab4910c23e902a2..5c5900e52ce64efe0a48d316192f2a2155723323 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -14500,6 +14500,7 @@ static void tcp_close_tcpip(void *arg) {
 
 void mg_lwip_handle_accept(struct mg_connection *nc) {
   struct mg_lwip_conn_state *cs = (struct mg_lwip_conn_state *) nc->sock;
+  if (cs->pcb.tcp == NULL) return;
 #if MG_ENABLE_SSL
   if (cs->lc->flags & MG_F_SSL) {
     if (mg_ssl_if_conn_accept(nc, cs->lc) != MG_SSL_OK) {