Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Server failed to bind. This is usually caused by another process being bound to the same port.

Discussion in 'Game Server Hosting' started by Brogan89, May 2, 2023.

  1. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    243
    Sorry if this is something obvious but it seems like a bug to me.
    I'm not able to start a server with the given ip/port

    When server loads I'm instantly calling StartServer using code
    Code (CSharp):
    1.             var config = MultiplayService.Instance.ServerConfig;
    2.             Debug.Log($"MultiplayService config: {JObject.FromObject(config)}");
    3.             var ip = config.IpAddress;
    4.             var port = config.Port;
    5.        
    6.             Debug.Log($"Starting server... {ip}:{port}");
    7.             UnityTransport.SetConnectionData(ip, port);
    8.        
    9.             if (!NetworkManager.Singleton.StartServer())
    10.             {
    11.                 Debug.LogError($"Failed to start server on {ip}:{port}");
    12.                 Application.Quit(1);
    13.                 return;
    14.             }
    I'm see errors in the server log:

    I've also tried using variations of the port, like port + 1 etc, so nothing seems to bind.


     
    Last edited: May 2, 2023
  2. lewisw_unity

    lewisw_unity

    Unity Technologies

    Joined:
    May 19, 2018
    Posts:
    1
    zakirshikhli and Brogan89 like this.
  3. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    243
    Hey thanks for the reply.

    I actually rolled back to latest 2021 LTS, and now its connecting fine... The package is still the same though, not sure how that makes a difference.

    But I'll try bind to 0.0.0.0 IP in future.

    Cheers.
     
    lewisw_unity likes this.
  4. Selmar

    Selmar

    Joined:
    Sep 13, 2011
    Posts:
    55
    I had the same problem, because I was somewhat blindly following the matchmaking sample, where they assign the IP given by the command line parameters to the transport's connection data. They must be setting the IP to 0.0.0.0 via the build configuration, but I missed this.
     
    Brogan89 likes this.