android java.net.ConnectException: Connection 127.0.0.1:8080 refused
今天学习网络连接遇到了一个问题就是:
android java.net.ConnectException: Connection 127.0.0.1:8080 refused
解决方法如下:
调试中通过android simulator模拟器链接localhost或者127.0.0.1,因为我在电脑上面建立了apache,我的代码大概就是
URL url = new URL(urlString);
URLConnection urlconn = url.openConnection();
但是报错了!!
Exception 1:java.net.ConnectException: localhost/127.0.0.1:8080 -
Connection refused
问题是这样的,android模拟器(simulator)把它自己作为了localhost,也就是说,代码中使用localhost或者127.0.0.1来访问,都是访问模拟器自己!这是不行的!
如果你想在模拟器simulator上面访问你的电脑,那么就使用android内置的IP 10.0.2.2 吧, 10.0.2.2 是模拟器设置的特定ip,是你的电脑的别名alias
记住,在模拟器上用10.0.2.2访问你的电脑本机
以上转自:http://80x86.javaeye.com/blog/539356
转载于:https://www.cnblogs.com/loughofdragon/archive/2011/05/23/2053971.html
android java.net.ConnectException: Connection 127.0.0.1:8080 refused相关推荐
- 【android】java.net.ConnectException: localhost/127.0.0.1:8080 - Connection refused
调试中通过android simulator模拟器链接localhost或者127.0.0.1,因为我在电脑上面建立了apache,我的代码大概就是 URL url = new URL(urlStri ...
- Spring RMI错误:java.rmi.ConnectException: Connection refused to host: 127.0.0.1
错误现象 在linux上部署RMI服务端程序后,测试无法通过,主要错误如下: Exception in thread "main" org.springframework.remo ...
- IDEA点击download source 报错:Caused by: java.rmi.ConnectException: Connection refused to host: 127.0.0.1
IDEA点击Download sources 报错:Caused by: java.rmi.ConnectException: Connection refused to host: 127.0.0. ...
- idea生成单元测试后运行报错:java.net.ConnectException: Connection refused:
从官网下载了一个最新的idea(2017.1.4 community),多一个一个类写了一个单元测试,测试代码都没写,然后运行测试,竟然报错,报错为Error connecting to 127.0. ...
- ftp连接 java.net.ConnectException: Connection refused
http://zhidao.baidu.com/question/245219177.html JAVA编写FTP连接报错java.net.ConnectException: Connection r ...
- java.rmi.ConnectException: Connection refused to host:
java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: java.net.Conn ...
- redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refu
今天在做Redis 测试的时候遇到一个错误,写一篇博客博客记录一下: 错误: redis.clients.jedis.exceptions.JedisConnecti ...
- JedisConnectionException: java.net.ConnectException: Connection refused
出现问题 我遇到的一个问题,在连接redis的时候出现了错误!错误如下: JedisConnectionException: java.net.ConnectException: Connection ...
- 记录一次读取hdfs文件时出现的问题java.net.ConnectException: Connection refused
公司的hadoop集群是之前的同事搭建的,我(小白一个)在spark shell中读取hdfs上的文件时,执行以下指令 >>> word=sc.textFile("hdfs ...
最新文章
- plt.figure(figsize(x,y))设置后后续程序都跟着改变,如何处理?走破解它!
- Interface 的本质用处
- spring源码分析之@ImportSelector、@Import、ImportResource工作原理分析
- 编程之美-寻找最大的k个数
- LeetCode 2099. 找到和最大的长度为 K 的子序列
- ant-design tree 设置默认选中状态_快速掌握文件夹位置的更改和文件的默认打开方式及重命名的操作...
- 关于struts2 中result type=stream
- 关于ddx/ddy重建法线在edge边沿上的artifacts问题
- php7 findandmodify,node.js – (mongoose / promises)如何检查文档是否是使用带有upsert的findOneAndUpdate创建的...
- 2018 noip 考前临死挣扎
- 医疗NLP相关数据集整理
- DELPHI利用WMI获取主板参数
- n2android,刚上车,中国移动N2开箱评测,好给力的说!
- 2376. 统计特殊整数--(每日一难phase2--day4)
- java 重载的特征_Java中方法的重载详解
- Proteus 8 中的激励源
- Python三目表达式
- linux log原理,linux系统日志管理工具logrotate之原理详述
- 蒙氏素材---创意时钟---三段卡 蒙氏教育
- 泽塔云在2022年Gartner中国区超融合市场竞争报告中被评为优秀厂商代表