java.net.ConnectException: failed to connect to /127.0.1.1 (port 8080)的解决办法
来源:互联网 发布:centos开机启动命令 编辑:程序博客网 时间:2024/06/05 06:27
当你启动Tomcat后,在浏览器中输入http://127.0.1.1:8080/xxx.xx,你会发现你可以找打你要找的东西。但是当你在Eclipse中运行测试代码后,JUnit会一直报出这样的错误:
Java.net.ConnectException: failed to connect to /127.0.1.1 (port 8080) after 5000ms: isConnected failed: ECONNREFUSED (Connection refused)
at libcore.io.IoBridge.isConnected(IoBridge.java:223)
at libcore.io.IoBridge.connectErrno(IoBridge.java:161)
at libcore.io.IoBridge.connect(IoBridge.java:112)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
at java.net.Socket.connect(Socket.java:843)
at com.android.okhttp.internal.Platform.connectSocket(Platform.java:131)
at com.android.okhttp.Connection.connect(Connection.java:101)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:179)
此时,你的第一反应可能是某出代码有问题或者是清单文件中某个权限忘加了,其实不是这样的。原来模拟器默认把127.0.0.1和localhost当做本身了,在模拟器上可以用10.0.2.2代替127.0.0.1和localhost,另外如果是在局域网环境可以用 192.168.0.x或者192.168.1.x(根据具体配置)连接本机,这样应该就不会报错了。
本文出自 “江城” 博客,请务必保留此出处http://523436424.blog.51cto.com/8575872/1548436
- java.net.ConnectException: failed to connect to /127.0.1.1 (port 8080)的解决办法
- android-java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 8080)解决方法
- android-java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 8080)解决方法
- java.net.ConnectException: Failed to connect to /127.0.0.1:7001
- 使用叶神模拟器无法访问本机服务器的问题(报错:java.net.ConnectException: failed to connect to /127.0.0.1 (port 5000) )
- 关于java.net.ConnectException: failed to connect to localhost/127.0.0.1
- 编写检测ip端口是否存在的工具类,解决异常ConnectException: failed to connect to /127.0.0.1 (port 12345): connect faile
- java.net.SocketTimeoutException: failed to connect to /192.168.56.1 (port 8080) after 5000ms
- java.net.SocketTimeoutException: failed to connect to /10.0..2.2 (port 8080) after 10000ms
- java.net.SocketTimeoutException: failed to connect to /192.168.1.233 (port 8080) after 10000ms
- java.net.SocketTimeoutException: failed to connect to /10.0..2.2 (port 8080) after 10000ms
- java.net.SocketTimeoutException: failed to connect to /10.0.2.2 (port 8080) after 10000ms
- Unable to connect to any hosts due to exception: java.net.ConnectException:...问题的解决
- Could not connect to '192.168.80.145' (port 22): Connection failed的解决办法(远程连不上xshell)
- Could not connect to '192.168.80.145' (port 22): Connection failed的解决办法(远程连不上xshell)
- 愚蠢的错误 Failed to connect to 127.0.0.1 port 8888 :conection refused
- 启用Tomcat时,报异常:failed to connect to localhost/127.0.0.1 (port 8080)
- Could not connect to '127.0.0.1' (port 22): Connection failed.
- sql查询中的null
- Android开发学习之路--Content Provider之初体验
- iOS面试题四
- Android资源文件assets和raw的比较
- 关于Canvas的一些用法
- java.net.ConnectException: failed to connect to /127.0.1.1 (port 8080)的解决办法
- stm32之GPIO的理解
- 帆软报表学习-快速入门
- 框架学习
- mysql 创建用户与授权、修改密码
- 《Go语言编程》中calc修改后可在Windows执行的源码
- Centos7.0 安装VNC后链接出现黑屏
- PHP验证登录用户名和密码
- 蓝桥杯 K好数