报错时的运行环境:

问题简述:

在andorid设置url为127.0.0.1:8080,结果在运行的时候报了Failed to connect to localhost/127.0.0.1

FATAL EXCEPTION: Thread-2
                 Process: com.catanddog, PID: 21754
                 java.lang.RuntimeException: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:8080
                 	at com.catanddog.LoginActivity$1$1.run(LoginActivity.java:83)
                 	at java.lang.Thread.run(Thread.java:764)
                 Caused by: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:8080

问题解决:

解决方法:使用ipconfig /all命令找到自己的ip地址,将127.0.0.1:8080改为192.168.56.1:8080

Localhost环回地址127.0.0.1是指设备本身。你的Android模拟器上没有运行服务器。

Logo

一站式 AI 云服务平台

更多推荐