Network connection does not work when starting server from command line

I exported my Unity netcode game to create a standalone server at some point. Therefore I tried to start my program from the command line.
When I execute the program from the explorer and navigate in my system to execute my Server() function with a button, everything is working alright and I can connect from a client to this server.
But when I execute the program from a command line with a line argument telling the system to immediately start the server without having me manually navigate through my menus, I can’t connect. I get errors on the client like:
[Netcode] Deferred messages were received for a trigger of type OnSpawn with key 9, but that trigger was not received within within 1 second(s).
and
[Netcode] NetworkObject (2) children not resolved to parents by the end of frame

On the server, I get the following error:

[Netcode] Deferred messages were received for a trigger of type OnSpawn with key 0, but that trigger was not received within within 1 second(s).

I get no errors, when I test this with instances that were opened from the explorer or when I host the server with the editor. I get similar errors if I deactivate the scene management in the NetworkManager. Launching a client from the command line and connecting it with a manually opened server works on the other hand.

To start the server I use these line arguments:

"C:\Users\user\Desktop\Versions\301\game.exe" -launch-as-server
"C:\Users\user\Desktop\Versions\301\game.exe" -launch-as-client 127.0.0.1

I use this code to start the server withing Unity:

private void Start() {
        string[] arguments = System.Environment.GetCommandLineArgs();

        string[] args = System.Environment.GetCommandLineArgs();
        for (int i = 0; i < args.Length; i++)
        {
            if(args[i] == "-launch-as-client" && i != args.Length-1)
            {
                Join(args[i+1]);
                continue;
            }
            else if (args[i] == "-launch-as-server")
                Server();
        }

        worldMenu.SetActive(false);
    }

    public void Host() //controlled by button
    {
        //start game
        GameObject.Find("GameManager").GetComponent<Manager>().activeMode = 1;
        SceneManager.LoadScene("ActiveGame", LoadSceneMode.Additive);
    }

    public void Join(string ip = "") //controlled by button
    {
        //server adress
        if (inputFieldIP.text.Length > 0)
        {
            NetworkManager.Singleton.GetComponent<UnityTransport>().SetConnectionData(inputFieldIP.text,(ushort)7777,"0.0.0.0");
        } else if (ip.Length > 0){
            NetworkManager.Singleton.GetComponent<UnityTransport>().SetConnectionData(ip,(ushort)7777,"0.0.0.0");
        }
        //start game
        GameObject.Find("GameManager").GetComponent<Manager>().activeMode = 2;
        SceneManager.LoadScene("ActiveGame", LoadSceneMode.Additive);
    }

    public void Server() //controlled by button
    {
        DirectoryInfo directory = new DirectoryInfo(Application.persistentDataPath + "/saves");
        string path = Application.persistentDataPath + "/saves/" + directory.EnumerateDirectories().OrderBy(d => d.GetFiles("WorldData.json")[0].LastWriteTimeUtc).Select(d => d.Name).Reverse().ToList()[0];
        //Debug.Log(Directory.Exists(path));
        if (Directory.Exists(path))
        {
            GameObject.Find("GameManager").GetComponent<Manager>().worldPath = path;
        }
        //start game
        //Debug.Log(GameObject.Find("GameManager").GetComponent<Manager>().worldPath);
        GameObject.Find("GameManager").GetComponent<Manager>().activeMode = 3;
        SceneManager.LoadScene("ActiveGame", LoadSceneMode.Additive);
        //Debug.Log(GameObject.Find("GameManager").GetComponent<Manager>().worldPath);
    }

Can someone please help me?! I have no idea what to do now and I read every thread regarding a similar issue that I could find.

Can you reproduce the issue in the editor by forcing that check on the command line argument to true? Might be easier to debug that way. Otherwise my first hunch is that it’s a script ordering issue, where your start method executes before other scripts have been properly initialized. You could try playing with the script execution order and see if it helps.

Thank you very much. Reproducing with if(true) worked and I found out, that for some reason the main scene was loaded twice. I guess this caused the issues.