【Android沒法訪問本地服務器(localhost/127.0.0.1)的解決方案】java
在Android開發中經過localhost或127.0.0.1訪問本地服務器時,會報Java.NET.ConnectException: localhost/127.0.0.1:8083 -Connection refused異常。android
爲何會報這個異常呢?由於Android模擬器自己把本身當作了localhost或127.0.0.1,而此時咱們又經過localhost或127.0.0.1訪問本地服務器,因此會拋出異常了。服務器
在在模擬器上能夠用10.0.2.2代替127.0.0.1和localhost;spa
參考:http://blog.csdn.net/surehao/article/details/23460123.net