Unable to Connect to Server on LAN

I built a multiplayer game using the UNET Transport Layer API. Everything works correctly if I run the server and client on the same machine (ip 127.0.0.1, port 26000).

When I attempt to run the client on another machine (same network), the client is not able to connect to the server. I don’t get an error message, the connection just times out.

Because everything appears to work correctly when running on the same machine, I think the issue has something to do with my network, firewall, Unity settings, or ip / port configuration rather than an issue with the code itself.

Details:

  • Both machines are running Windows 10
  • The server and client are running in the Unity editor (2019.1.0)
  • The client is attempting to connect to the IPv4 of the server machine (192.168.1.87) on port 26000.
  • The Unity editor is allowed through Windows Defender Firewall on both machines

Initialize Server

hostId = NetworkTransport.AddHost(hostTopology, port, serverIP);
NetworkTransport.Init();
hostTopology = new HostTopology(connectionConfig, maxUsers);

Initialize Client

hostId = NetworkTransport.AddHost(hostTopology, port, serverIP);
NetworkTransport.Init();
hostId = NetworkTransport.AddHost(hostTopology, 0);
clientId = NetworkTransport.Connect(hostId, serverIP, port, 0, out error);

Is the private address of the server machine really bound? In other words is the server listening on 192.168. etc… or just 127?

1 Like