diff --git a/src/Tgstation.Server.Host/Components/InstanceManager.cs b/src/Tgstation.Server.Host/Components/InstanceManager.cs
index 085dc79c32..0d003e0a91 100644
--- a/src/Tgstation.Server.Host/Components/InstanceManager.cs
+++ b/src/Tgstation.Server.Host/Components/InstanceManager.cs
@@ -481,7 +481,7 @@ namespace Tgstation.Server.Host.Components
// This runs before the real socket is opened, ensures we don't perform reattaches unless we're fairly certain the bind won't fail
// If it does fail, DD will be killed.
- SocketExtensions.BindTest(serverPortProvider.HttpApiPort);
+ SocketExtensions.BindTest(serverPortProvider.HttpApiPort, true);
}
///
diff --git a/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs b/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs
index 04e00f5536..e211b982d2 100644
--- a/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs
+++ b/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs
@@ -120,7 +120,7 @@ namespace Tgstation.Server.Host.Components.Session
{
try
{
- SocketExtensions.BindTest(port);
+ SocketExtensions.BindTest(port, false);
}
catch (SocketException ex) when (ex.SocketErrorCode == SocketError.AddressAlreadyInUse)
{
diff --git a/src/Tgstation.Server.Host/Extensions/SocketExtensions.cs b/src/Tgstation.Server.Host/Extensions/SocketExtensions.cs
index 6d4ae76323..b5f28c6a7f 100644
--- a/src/Tgstation.Server.Host/Extensions/SocketExtensions.cs
+++ b/src/Tgstation.Server.Host/Extensions/SocketExtensions.cs
@@ -12,12 +12,21 @@ namespace Tgstation.Server.Host.Extensions
/// Attempt to exclusively bind to a given .
///
/// The port number to bind to.
- public static void BindTest(ushort port)
+ /// If IPV6 should be tested as well.
+ public static void BindTest(ushort port, bool includeIPv6)
{
using var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ExclusiveAddressUse, true);
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, false);
- socket.Bind(new IPEndPoint(IPAddress.Any, port));
+ if (includeIPv6)
+ socket.DualMode = true;
+
+ socket.Bind(
+ new IPEndPoint(
+ includeIPv6
+ ? IPAddress.IPv6Any
+ : IPAddress.Any,
+ port));
}
}
}