diff --git a/src/d_net.c b/src/d_net.c
index 7f16c302d1c3267c0f1b5476b3e4b10cbfb6593f..98fe71ab8d55c5149cd4997b73cc127421c4ac50 100644
--- a/src/d_net.c
+++ b/src/d_net.c
@@ -716,6 +716,12 @@ void Net_CloseConnection(INT32 node)
 	if (!node)
 		return;
 
+	if (node >= MAXNETNODES) // prevent invalid nodes from crashing the game
+	{
+		CONS_Alert(CONS_WARNING, M_GetText("Net_CloseConnection: invalid node %d detected!\n"), node);
+		return;
+	}
+
 	nodes[node].flags |= NF_CLOSE;
 
 	// try to Send ack back (two army problem)