android 127.0.0.1/localhost connection refused,在模拟器上应该用10.0.2.2访问你的电脑本机
调试中通过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访问你的电脑本机
android 127.0.0.1/localhost connection refused,在模拟器上应该用10.0.2.2访问你的电脑本机的更多相关文章
- 【MongoDB】 Failed to connect to 127.0.0.1:27017, reason: Connection refused
由于项目需要,在一台虚拟机上安装了MongoDB,但是在启动的时候,出现如下错误: [root@localhost bin]# ./mongo MongoDB shell version v3.4.0 ...
- 解决git Failed to connect to 127.0.0.1 port xxxx: Connection refused
某天,用git拉取,提交代码的时候出现了git Failed to connect to 127.0.0.1 port xxxx: Connection refused的问题, 开始百度,看了一通.都 ...
- Error: client: etcd cluster is unavailable or misconfigured; error #0: dial tcp 127.0.0.1:4001: getsockopt: connection refused
配置docker网络flannel时,配置etcd的key的时候出现以下错误 Error: client: etcd cluster is unavailable or misconfigured; ...
- Failed to connect to 127.0.0.1 port 1080: Connection refused package 问题解决方法
错误: fatal: unable to access 'https://github.com/******': Failed to connect to 127.0.0.1 port 1080: C ...
- zabbix-Get value from agent failed: cannot connect to [[127.0.0.1]:10050]: [111] Connection refused
监控zabbix服务端这台服务器,然后显示Get value from agent failed: cannot connect to [[127.0.0.1]:10050]: [111] Conne ...
- 我遇到的错误curl: (7) Failed to connect to 127.0.0.1 port 1086: Connection refused
今天我用curl命令,无论如何都是出现: curl: (7) Failed to connect to 127.0.0.1 port 1086: Connection refused 找了很久,不知道 ...
- curl: (7) Failed to connect to 127.0.0.1 port 1086: Connection refused
今天我用curl命令,无论如何都是出现: curl: (7) Failed to connect to 127.0.0.1 port 1086: Connection refused 找了很久,不知道 ...
- zabbix 启到不起来:active check configuration update from [127.0.0.1:10051] started to fail (cannot connect to [[127.0.0.1]:10051]: [111] Connection refused)
cat /var/log/zabbix_agent_log 查看日记出现报错:active check configuration update from [127.0.0.1:10051] star ...
- git时 Failed to connect to 127.0.0.1 port 1080: Connection refused
在公司换了一台电脑之后发现git clone 和 npm install都失败,报错为 fatal: unable to access 'https://github.com/netease-im/N ...
随机推荐
- 在做和sap系统集成的一点心得
最这一个月和sap做集成,把主数据中的数据写入到sap系统中,做集成就离不开联调,平时开发中,一个复杂点的系统还容易出问题,涉及到两个系统,由于两个或多个系统来自不同的厂家,各个厂家的开发对业务的理解 ...
- unity3d的三种平面坐标系
unity3d有如下三种平面坐标系: 1.屏幕坐标系 2.视口坐标系viewport 3.GUI坐标系
- Android之ImageButton控件基础操作
控件绑定(前台对应控件的id属性要设置为imageButton_light) private ImageButton imageButton_light;//定义一个ImageButton控件对象,名 ...
- Powershell - 获取OS版本信息和catpion信息
Environment 获取 OSversion: $OSVersion = [System.Environment]::OSVersion.Version WMI获取Caption: $OSCap ...
- 将Cmder添加到系统右键菜单中
1.把 Cmder 加到环境变量 把Cmder.exe存放的目录添加到系统环境变量: 加完之后,Win+r一下输入cmder,即可. 2.添加 cmder 到右键菜单:环境变量添加后,在任意文件夹中即 ...
- Jumpserver web界面跳板机
Jumpserver.org 普通用户 仪表盘 查看主机 上传下载 访问官网 欢迎使用Jumpserver开源跳板机系统 帮助 Log out 查看资产 仪表盘 资产管理 查看资产 主机详细信息列表 ...
- VUE详解
渐进式框架 声明式渲染(无需关心如何实现).组件化开发.客户端路由(vue-router).大规模的数据状态(vuex).构建工具(vue-cli) 全家桶:vue.js+vue-router+vue ...
- Unity3D发布安卓报错permisson denied的解决
没有打开SD卡的写入权限 unity提供了sd卡权限修改的参数:
- Verilog语言:还真的是人格分裂的语言
人气腹语术师天愿在现场披露了被人偶搭档夺取灵魂的腹语术师将妻子杀害的表演节目.天愿真的陷入了多重人格,命令自己杀害妻子和子的人偶的人格出现了.为了不(让自己)杀害和弟子登川有外遇的妻子,天愿提出委托想 ...
- vue路由使用
<body> <div id="itany"> <div> <!--使用router-link组件来定义导航,to属性指定链接url--& ...