Cant Make Remote Connection

i have a multiplayer game with netcode. when i want to connect the client to server i cant make remote connection and everything only works on 127.0.0.1.

NOTE:
mounts ago i had made another multiplayer project and in that i could see a “Allow Remote Connection”
option in unity transport witch i dont see that anymore

Thanks. But the previous project is gone.
and where is network settings?
do you mean unity network accessibility in windows?

If the server is hosted privately on a local machine, then the network configuration (aka router, firewall) needs to be set up to allow clients to connect to this machine. Specifically, on the router behind which the server is you need to set up “port forwarding” for this to work.

Whatever this “allow remote connection” option did, it could not have done the port forwarding part on the router, nor unblock app/port specific traffic on the firewall (if any).

I did the port forwarding on router. at this project and in the previous one.
the point is since that check box(allow remote connection) doesnt get checked, the game doesnt connect
to any other node. event in local area network

FOUND THAT.
looks like unity just removed “allow remote connection” in newer versions.
i found (inbound rule) in windows firewall witch were set to block any connection to the unityEditor.exe
deleting that did solve the problem

I think the “Allow Remote Connection” option was removed in Unity 2020.3 and later versions. To enable remote connections, you need to configure your Unity project for NAT punch-through. This involves opening specific ports on your router and firewall.
Open the Unity Editor and select the project you want to configure.
Go to Edit > Project Settings > Networking.
Under NAT Traversal, enable Use Unity Relay Server.
Click Apply and then Save. Thank you.


This button is available in Unity 6 preview, but I can’t find this setting through the code:

Do you have data on how to enable remote connection via the code?

The NetworkManager Inspector has a custom editor. Many of the settings aren’t actually fields in a class but rather settings stored in EditorPrefs / PlayerPrefs.

You’d have to inspect the NGO code to learn about the corresponding keys, and changing a value is not guaranteed to be picked up by NGO either because it may have been done after initialization or sometimes it requires calling another “apply” method of sorts that is internal.

You can leave AllowRemoteConnection enabled if you’re behind a router. Unless you set up port forwarding on the router the open port will only be accessible from within your local network.

Probably giving access to fields/properties that we can’t change properly was a terrible idea from the point of view of encapsulating the NetworkManager code.

I spent literally half of today to understand that we cannot change the settings of the NetworkManager after its initialization!

Moreover, it did not cause any exceptions, errors and the like, it simply did not affect ANYTHING!

I only managed to figure it out when I called

netstat -tuln | grep 7777

on a remote server, I saw the values 127.0.0.1 in the listened address, although I changed it to 0.0.0.0 directly through the code

using Unity.Netcode;
using Unity.Netcode.Transports.UTP;
using UnityEngine;
public class Server : MonoBehaviour
{
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        // Убедитесь, что NetworkManager присутствует на этом объекте или в сцене
        NetworkManager networkManager = NetworkManager.Singleton;
        if (networkManager == null)
        {
            Debug.LogError("NetworkManager не найден!");
            return;
        }
        // Настройка NetworkConfig при необходимости
        ConfigureServer(networkManager);
        // Подписываемся на событие подключения клиента
        networkManager.OnClientConnectedCallback += OnClientConnected;
        // Запуск сервера
        networkManager.StartServer();
        Debug.Log($"Запуск в режиме сервера на {host}:{port}");
    }
    private void OnClientConnected(ulong clientId)
    {
        Debug.Log($"Клиент с ID {clientId} подключился.");
    }
    // Не забудьте отписаться от события при завершении работы
    private void OnDestroy()
    {
        NetworkManager networkManager = NetworkManager.Singleton;
        if (networkManager != null)
        {
            networkManager.OnClientConnectedCallback -= OnClientConnected;
        }
    }
    const string host = "0.0.0.0";
    const int port = 7777;
    private void ConfigureServer(NetworkManager networkManager)
    {
        // Настройка IP и порта для сервера
        networkManager.NetworkConfig.ConnectionData = System.Text.Encoding.UTF8.GetBytes("DefaultConnectionData");
        // Настройка адреса и порта для сервера
        UnityTransport transport = networkManager.GetComponent<UnityTransport>();
        if (transport != null)
        {
            transport.ConnectionData.Address = host;
            transport.ConnectionData.Port = port;
            transport.UseWebSockets = true;
            Debug.Log($"Сервер настроен для использования WebSocket на {host}:{port}");
        }
        else
        {
            Debug.LogError("UnityTransport не найден на NetworkManager!");
        }
        // Другие стандартные настройки NetworkManager (если нужно)
        networkManager.NetworkConfig.ConnectionApproval = false;
        networkManager.NetworkConfig.NetworkTransport = transport;
    }
}

before calling the StartServer() method;

Insane

Assuming that I am not trying to communicate with Voyager(s) and that I just need two (or more) devices on the local network to see each other, is Allow Remote Connection for this or not? I think I am missing a very tiny but very important detail here.
It seems that all the guides, docuemnation, and tutorials I have found assume that I already know how to do the multipayer, but if I did I would not be here reading them!
Assuming that my 1000 previous attempts have made me feel like Wile E. Coyote, how should I do it?

Small detail: I want within the program to see the local IP so that no external tools are needed to find out.
I use
IPAddress[ ] Lst = Dns.GetHostAddresses(Dns.GetHostName());
And I get the last one in the list.
And on my main computer it works, but on the second computer I get “1” as the last byte.

By enabling allowremoteconnection, on the first computer, when I launched the game, it asked me for permission to access the network. copying the compiled game to a second computer and launching it did not ask for any atauthorization, in fact it does not connect.

Also, as long as I run two instances on the same computer, they see each other correctly, either by setting 127.0.0.1 or by setting the true local IP.

There is no guarantee that this will provide you with the intended IP. You have to allow the user to select the IP. Perhaps the user wants to use Wifi, or the third Ethernet port out of four because the machine is connected to four different local networks - admittedly rare but these are the things you’ll encounter out in the wild.

In fact that is the default but I still leave the option of choosing a specific address.

  1. Is there any way to automate so that the user doesn’t get bored doing too much work?
  2. How do I (as programmer and user) figure out which address to enter? So far I have tried with the ip obtained from ipconfig, and also with the addresses through which Dukto works, with this result.