diff --git a/src/Servers/Kestrel/Transport.Sockets/src/SocketConnectionContextFactory.cs b/src/Servers/Kestrel/Transport.Sockets/src/SocketConnectionContextFactory.cs
index b096b7bcf26c4d21f8ce2226501b0cf1a0aaf16a..71f3cdc0fc0cc6544059863505d7a1024a9061ba 100644
--- a/src/Servers/Kestrel/Transport.Sockets/src/SocketConnectionContextFactory.cs
+++ b/src/Servers/Kestrel/Transport.Sockets/src/SocketConnectionContextFactory.cs
@@ -20,7 +20,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets
         private readonly ISocketsTrace _trace;
         private readonly int _settingsCount;
         private readonly QueueSettings[] _settings;
-        private int _settingsIndex;
+
+        // long to prevent overflow
+        private long _settingsIndex;
 
         /// <summary>
         /// Creates the <see cref="SocketConnectionContextFactory"/>.