---
title: "java.net.ConnectException: localhost/127.0.0.1:8088 - Connection refused"
author: "runfeel"
date: "2012-12-19T17:10:00Z"
tags: []
slug: "java-net-connectexception-localhost-127-0-0-1-8088-connection-refused"
draft: false
lastmod: "2013-03-04T15:40:46Z"
id: 1821169
url: "https://runfeel.iteye.com/blog/1821169"
---

## [java.net.ConnectException: localhost/127.0.0.1:8088 - Connection refused](http://www.blogjava.net/anchor110/articles/355872.html)

描述：  
在做注册功能的时候，向本地服务器：127.0.0.1发送注册请求，logcat显示出错信息：

java.net.ConnectException: localhost/127.0.0.1:8088 - Connection refused

解决办法：  
弃用127.0.0.1来访问服务器，改用本机的真实IP。

问题解释：  
摘自:http://80x86.iteye.com/blog/539356

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访问你的电脑本机。