- Home /
Failed to connect to localhost port 80: Connection refused
Unity WWW class can connect to outside servers, but cannot connect to localhost. I have a crossdomain.xml in the localhost root. It is the PHP.EXE built in web server. It does work with other browsers. Unity 5.3.0f4
Can you help me why it doesn't work?
public class AppManager : MonoBehaviour {
public string url = "http://localhost";
public Text Result;
public Text Error;
void Start() {
StartCoroutine(CallURL());
}
IEnumerator CallURL() {
WWW www = new WWW(url);
print("www started");
yield return www;
print(www.error);
print(www.text);
Result.text = www.text;
Error.text = www.error;
}
}
Answer by zbalai · Dec 15, 2015 at 05:24 PM
After investing six hours into this matter I have the following solution: It seems PHP.EXE default built in web server is refusing to answer to Unity 3D editor or built EXE files. One solution is to use EasyPHP or WAMP to start an Apache server and that will give a proper answer to Unity 3D too. Merry Christmas BTW :)
Answer by nxrighthere · Jan 12, 2016 at 09:51 AM
You can use PHP's built-in web server, but you need to make PHP listen on all interfaces using a command-line argument: -S 0.0.0.0:80