Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

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:
    244
    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:
    3
    zakirshikhli and Brogan89 like this.
  3. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    244
    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:
    61
    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.
  5. JS14

    JS14

    Joined:
    Mar 21, 2022
    Posts:
    1

    Hi, so the problema was the unity editor version?
     
  6. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    244
    Nah putting "0.0.0.0" is the fix