I've been search AE, SO and Google for many hours and found many examples of people wanting to connect their PC to the emulator. I've also run across some that wish to connect their device to their server on a PC. I want to connect my device, to an emulator running on a PC. I've tried the examples given in the documentation but I still haven't gotten this to work.

I would like to have my device (real device, Nexus 7) create a Hotspot that my PC is connected to. In the PC, an emulator is running that has a socket open on port 40000. I'm getting ECONNREFUSED errors when trying to connect my device to the emulator. Here's what I'm doing:

Connecting device to emulator (through PC)

Device tries to create a Socket connection to the emulator through the PC. The IP of my PC is so that is what the device use as destination IP. The connection fails however, with an ECONNREFUSED message.

Forwarding using ADB and telnet

On the PC I've tried to forward port 40000 to the emulator using:

adb forward tcp:40000 tcp:40000


redir add tcp:40000:40000

over telnet to the emulator.

When running the adb forward command I get a listening port on the PC as such:


Notice that the listening IP is

When running the redir command, I can see no listening port using netstat.

Testing connection from device to PC

To test the connection "parts", I've used SocketTest (http://sourceforge.net/projects/sockettest/) on my PC.

If I use it as a server, listening on port 40000. Then my device connects to it just fine using

Testing connection from PC to emulator

When using SocketTest as a client to connect to it also connects fine to the emulator.

However, when using the external IP:, SocketTest also gets connection refused!

Possible problems

It seems to me that my PC doesn't realise it should route to although the commands I've entered claim to do so in the docs (http://developer.android.com/tools/devices/emulator.html#redirection and http://developer.android.com/tools/help/adb.html#forwardports)

Firewall is turned off.

  • 2
    I'm slightly confused about what's connecting to what, I can't work out what "device" is in your question. Sometimes it seems to be your PC, and sometimes it seems to be the Android emulator, and sometimes neither? Also depending on what is what, it sounds like you think this could be a Windows routing issue rather than a Android issue, in which case you'd be better off posting this in SuperUser.com as the WIndows stuff is off-topic here.
    – GAThrawn
    Dec 19, 2013 at 17:44
  • Sorry I wasn't clear enough. I do consider it an Android issue however since the Android docs claim this is possible using adb or telnet. I have rephrased the question to make it more clear.
    – span
    Dec 20, 2013 at 8:17

1 Answer 1


The problem here is that ADB forwarding attaches itself to the local loopback interface (, and you have no forwarding from the LAN interface ( to the loopback interface. The method you can use to achieve this depends on your platform. I don't know what you could use in Windows, but on Linux you can use rinetd and on OSX you can use ipfw


Add the following lines to your /etc/rinetd.conf:

# bindaddress    bindport  connectaddress  connectport   40000       40000

Then restart rinetd with service rinetd restart or /etc/init.d/rinetd restart.


ipfw add fwd,40000 tcp from any to dst-port 40000

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .