[英]Login register android app cant coonect to local server (connection refused)
This application registers users in a database. 该应用程序在数据库中注册用户。 When I click the register button, I get
Connection Refused error
in my logs. 单击注册按钮时,日志中
Connection Refused error
。
My login and register localhost IP is : 127.0.0.1. 我的登录和注册localhost IP是:127.0.0.1。 I searched many websites and articles and they wrote >> you should change 127.0.0.1 to 10.0.2.2 but finally I didn't succeed.
我搜索了许多网站和文章,他们写了>>,您应该将127.0.0.1更改为10.0.2.2,但最终我没有成功。 My emulator is Nox player.
我的模拟器是Nox播放器。
// Server user login url
public static String URL_LOGIN = "http://127.0.0.1:80/android_login_api/login.php";
// Server user register url
public static String URL_REGISTER = "http://127.0.0.1:80/android_login_api/register.php";
Well ! 好 ! Issue can be of the port you are referring to which is
80
in your case. 问题可能出在您所指的端口,在您的情况下为
80
。 You can try changing the port to 8080
. 您可以尝试将端口更改为
8080
。 In that case the Addresses may look like this: 在这种情况下,地址可能看起来像这样:
// Server user login url
public static String URL_LOGIN = "http://127.0.0.1:8080/android_login_api/login.php";
// Server user register url
public static String URL_REGISTER = "http://127.0.0.1:8080/android_login_api/register.php";
Or try like this : 或者像这样尝试:
// Server user login url
public static String URL_LOGIN = "http://10.0.2.2:8080/android_login_api/login.php";
// Server user register url
public static String URL_REGISTER = "http://10.0.2.2:8080/android_login_api/register.php";
Double check: 再检查一遍:
INTERNET
permission in your Manifest INTERNET
权限 Port
you are listening to must be open
for connections. Port
必须open
以进行连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.