# Player not connecting???

**URL:** https://discussions.unity.com/t/player-not-connecting/450374
**Category:** Multiplayer & Networking
**Created:** [July 16, 2011, 11:07pm UTC](https://discussions.unity.com/t/player-not-connecting/450374 "2011-07-16T23:07:59Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![anon\_8227815](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@anon\_8227815](https://discussions.unity.com/u/anon_8227815)
#### Post date: [July 16, 2011, 11:07pm UTC](https://discussions.unity.com/t/player-not-connecting/450374/1 "2011-07-16T23:07:59Z")

</div>

Hello when i start a game and when my friend is trying to connect it won’t work for some reason he will click the connect button but nothing happens please help.

using UnityEngine;  
using System.Collections;  
using System;

public class Multiplayer : MonoBehaviour  
{

public string connectToIp = “127.0.0.1”;  
public int connectPort = 25000;  
public bool useNAT = false;  
public string ipaddress = “”;  
public string port = “”;

string playerName = “Enter a name”;

void OnGUI()  
{  
if (Network.peerType == NetworkPeerType.Disconnected)  
{  
if (GUILayout.Button(“Connect”))  
{  
if (playerName != “Enter a name”)  
{  
Network.Connect(connectToIp, connectPort);  
PlayerPrefs.SetString(“PlayerName”, playerName);  
}  
}

if (GUILayout.Button(“Start Server”))  
{  
if (playerName != “Enter a name”)  
{  
Network.InitializeServer(32, connectPort, true);

foreach (GameObject go in FindObjectsOfType(typeof(GameObject)))  
{  
go.SendMessage(“LoadedLevel”, SendMessageOptions.DontRequireReceiver);  
}  
PlayerPrefs.SetString(“Enter a name”, playerName);  
}  
}

playerName = GUILayout.TextField(playerName);  
connectToIp = GUILayout.TextField(connectToIp);  
connectPort = Convert.ToInt32(GUILayout.TextField(connectPort.To String()));  
}  
else  
{  
if (Network.peerType == NetworkPeerType.Connecting) GUILayout.Label(“Connect Status: Connecting”);  
else if (Network.peerType == NetworkPeerType.Client)  
{  
GUILayout.Label(“Connect Status: Client”);  
GUILayout.Label("ping to Server: " + Network.GetAveragePing(Network.connections[0]));  
}  
else if (Network.peerType == NetworkPeerType.Server)  
{  
GUILayout.Label(“Connection Status: Server:”);  
GUILayout.Label("ping to Server: " + Network.connections.Length);  
if (Network.connections.Length \>= 1)  
GUILayout.Label("ping to Server: " + Network.GetAveragePing(Network.connections[0]));  
}

if (GUILayout.Button(“Disconnect”))  
Network.Disconnect(200);

ipaddress = Network.player.ipAddress;  
port = Network.player.port.ToString();  
[//GUILayout.Label](https://GUILayout.Label)("IP Address: " + ipaddress + “:” + port);  
}  
}

void OnConnectedToServer()  
{  
foreach (GameObject go in FindObjectsOfType(typeof(GameObject)))  
{  
go.SendMessage(“LoadedLevel”, SendMessageOptions.DontRequireReceiver);  
}  
}  
}

---

<div class="post-metadata">

### Author: ![appels](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/appels/32/495192_2.png) [@appels](https://discussions.unity.com/u/appels)
#### Post date: [July 17, 2011, 12:18am UTC](https://discussions.unity.com/t/player-not-connecting/450374/2 "2011-07-17T00:18:13Z")

</div>

is your friend on the same pc as you : public string connectToIp = “127.0.0.1”; ?

---

<div class="post-metadata">

### Author: ![zine92](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/zine92/32/462446_2.png) [@zine92](https://discussions.unity.com/u/zine92)
#### Post date: [July 17, 2011, 12:34am UTC](https://discussions.unity.com/t/player-not-connecting/450374/3 "2011-07-17T00:34:23Z")

</div>

127.0.0.1 means local. So both of you on same network?

---

<div class="post-metadata">

### Author: ![anon\_8227815](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@anon\_8227815](https://discussions.unity.com/u/anon_8227815)
#### Post date: [July 19, 2011, 12:39am UTC](https://discussions.unity.com/t/player-not-connecting/450374/4 "2011-07-19T00:39:01Z")

</div>

i changed the ip address to my own ip but still does not work?

---

<div class="post-metadata">

### Author: ![anon\_8227815](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@anon\_8227815](https://discussions.unity.com/u/anon_8227815)
#### Post date: [July 19, 2011, 12:39am UTC](https://discussions.unity.com/t/player-not-connecting/450374/5 "2011-07-19T00:39:33Z")

</div>

And we are using different computers

---

<div class="post-metadata">

### Author: ![appels](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/appels/32/495192_2.png) [@appels](https://discussions.unity.com/u/appels)
#### Post date: [July 19, 2011, 5:58am UTC](https://discussions.unity.com/t/player-not-connecting/450374/6 "2011-07-19T05:58:11Z")

</div>

are you on the same ip subnet ? or is your friend at his home ? do you know anything about ip port forwarding ? have you got a router/firewall thats blocking the port ? If you don’t understand what i’m asking, you will have to google the questions and go from there.

---

<div class="post-metadata">

### Author: ![anon\_8227815](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@anon\_8227815](https://discussions.unity.com/u/anon_8227815)
#### Post date: [July 22, 2011, 3:54am UTC](https://discussions.unity.com/t/player-not-connecting/450374/7 "2011-07-22T03:54:35Z")

</div>

The firewall is not blocking it at all and my friend is at his house
