'HTTP server in Android emulator not accessible from host

On my Android emulator device I have deployed HTTP server on port 8080

> adb -s 127.0.0.1 shell
generic_x86:/ $ netstat -atn
Active Internet connections (established and servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp6       0      0 :::8080                 :::*                    LISTEN
tcp6       0      0 ::ffff:10.0.2.16:47344  ::ffff:66.102.1.18:5228 ESTABLISHED

However, when I try to access it from the host the port seems to closed:

curl http://127.0.0.1:8080
curl : Unable to connect to the remote server

In my host Resource Manager I am not seeing any process listening on that port

enter image description here

Why is the port not visible on host?



Solution 1:[1]

The official documentation says that (thanks to @Selvin):

Each instance of the emulator runs behind a virtual router/firewall service that isolates it from your development machine network interfaces . and then explain how to open specific ports by

Using network redirection

In my case implementation the steps helped

telnet localhost 5554
auth ... # with token
redit add tcp:8080:8080
quit

And voila, HTTP server has become available on my host machine. Now,

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1