Cannot Connect to Server.

Recently Started Learning how to do Net Code VIA tutorial, and the code seems to be working right. I can join the server if I open two instances of the game.

However, my friend in another state and I tried to connect to the same server and it wouldn’t allow us to.

Sadly I didn’t put any debugs in for connection while we were testing.

It shows the server after either of us created it but we cannot join.

Here’s The Script… Hopefully one of you can take a quick glance at it and see if and what is missing.

    var gameName:String = "JuiceBox Trosity";
    var playerPrefab:GameObject;
    var spawnObject:Transform;
    
    private var btnX : float;
    private var btnY : float;
    private var btnH : float;
    private var btnW : float;
    private var refreshing:boolean;
    private var hostData:HostData[];
    
    function Start(){
    	btnX = Screen.width * 0.09;
    	btnY = Screen.width * 0.09;
    	btnH = Screen.width * 0.1;
    	btnW = Screen.width * 0.1;
    }
    //Starts Server//
    function startServer(){
    	Network.InitializeServer(8, 25001, !Network.HavePublicAddress);
    	MasterServer.RegisterHost(gameName, "JuiceBoxTrocityTest", "This is a Networking Server Test");
    }
    
    function refreshHostList(){
    	MasterServer.RequestHostList(gameName);
    	refreshing = true;
    	
    }
    
    function Update(){
    	if(refreshing){
    		if (MasterServer.PollHostList().Length > 0){
    		refreshing = false;
    		Debug.Log(MasterServer.PollHostList().Length);
    		hostData = MasterServer.PollHostList();
    		}
    	}
    }
    
    function spawnPlayer(){
    	Network.Instantiate(playerPrefab, spawnObject.position, Quaternion.identity, 0);
    }
    
    //message logs//
    function OnServerInitialized(){
    	Debug.Log("Server Initialized!");
    	spawnPlayer();
     }
     
     function OnConnectedToServer(){
     	spawnPlayer();
     }
    
    function OnMasterServerEvent(mse:MasterServerEvent){
    
    	if(mse == MasterServerEvent.RegistrationSucceeded){
    	Debug.Log("Registration Succeeded");
    	}
    	
    
    }
    //GUI
    function OnGUI(){
    
    	//Creates Gui Boxes//
    	if(!Network.isClient && !Network.isServer){
    		if(GUI.Button(Rect( btnX, btnY, btnH, btnW),"Start New Server")){
    		Debug.Log("Starting Server");
    		startServer();
    		}
    		if(GUI.Button(Rect( btnX, btnY * 1.2 + btnH, btnH, btnW),"Refresh Hosts")){
    		Debug.Log("Refreshing");
    		refreshHostList();
    		}
    		if(hostData){
    			for(var i:int = 0; i<hostData.length; i++){
    				if(GUI.Button(Rect(btnX * 1.5 + btnW, btnY*1.2 + (btnH * i), btnW* 3, btnH* 0.5), hostData*.gameName)){*

_ Network.Connect(hostData*);*_

* }*
* }*
* }*
* }*
}

This sounds more like a firewall issue than a Unity coding issue. Have you tried connecting using another computer on your local network through your internal LAN IP? If connections over the local network work, you probably need to do some port forwarding on your router to make your machine accessible to the outside world.

Have the Answer thanks to David!

#pragma strict
 
class NetworkManagerScript extends MonoBehaviour {
 
        public var ServerName : String = "JuiceBox Trosity";
 
        public var PlayerPrefab : GameObject;
        public var SpawnPointObject : Transform;
 
        public var MaxPlayers : int = 8;
        public var Port : int = 25001;
 
        //public var serverIP : String = 127.0.0.1;
         
        private var isRefreshing : boolean;
        private var hostData : HostData[];
 
        private var connected : int = 0; // 0 = no connection, 1 = client, 2 = host
 
        /* host stuff */
 
        function StartServer () {
                Debug.Log("Starting Server");
                Network.InitializeServer(MaxPlayers, Port, !Network.HavePublicAddress);
                MasterServer.RegisterHost(ServerName, "JuiceBoxTrocityTest", "This is a Networking Server Test");
        }
         
        function OnServerInitialized () {
                connected = 2;
                Debug.Log("Server Initialized!");
                SpawnPlayer ();
        }
 
        function OnMasterServerEvent(mse : MasterServerEvent) {
                if(mse == MasterServerEvent.RegistrationSucceeded) Debug.Log("Registration Succeeded");
                else Debug.Log("Registration Unsuccessful!"); // this is a hard word to spell <...<
        }
 
        /* client stuff */
 
        function RefreshHosts () {
                Debug.Log("Refreshing hosts!");
                MasterServer.RequestHostList(ServerName);
                isRefreshing = true;      
        }
 
        function OnConnectedToServer () {
                connected = 1;
                Debug.Log("Connected to server!");
                SpawnPlayer ();
        }
 
        /* universal */
 
        function Update () {
                if(isRefreshing) {
                        if (MasterServer.PollHostList().Length > 0) {
                                isRefreshing = false;
                                Debug.Log(MasterServer.PollHostList().Length);
                                hostData = MasterServer.PollHostList();
                        }
                }
        }
         
        function SpawnPlayer () {
                Debug.Log("Spawning player prefab!");
                Network.Instantiate(PlayerPrefab, SpawnPointObject.position, Quaternion.identity, 0);
        }
 
        function OnDisconnectedFromServer (info : NetworkDisconnection) {
               
                if (Network.isServer) {
                        Debug.Log("Local server connection disconnected");
                }
                else {
                        if (info == NetworkDisconnection.LostConnection)
                                Debug.Log("Lost connection to the server");
                        else
                                Debug.Log("Successfully diconnected from the server");
                }
 
                connected = 0;
        }
 
 
 
        function OnGUI () {
 
                if(connected == 0) {
 
                        if(!Network.isClient && !Network.isServer) {
 
                                if(GUILayout.Button("Start New Server")) StartServer ();
                                if(GUILayout.Button("Refresh Hosts")) RefreshHosts ();
 
                                if(hostData)
                                        for(var i : int = 0; i < hostData.length; i++)
                                                if(GUILayout.Button(hostData*.gameName))*

Network.Connect(hostData*);*
}

}
else if(connected == 1) {
GUILayout.Label(“Is playing!”);
}
else if(connected == 2) {
GUILayout.Label(“Is hosting!”);
if(GUILayout.Button(“Close server!”)) {
Network.Disconnect();
MasterServer.UnregisterHost();
}

}
}
}