'Unable to 'ping' local network from android using adb or android studio

I am tryin to establish tcp connection in my app and test it on VM host with local IP. On the host I open a tcp port 4444.

To test why the connection cannot be established I decided to first try a simple 'ping'. On the Host I do"

C:\WINDOWS\system32>ping -c 1 192.168.1.66

Pinging 192.168.1.66 with 32 bytes of data:
Reply from 192.168.1.66: bytes=32 time<1ms TTL=64
Reply from 192.168.1.66: bytes=32 time<1ms TTL=64
Reply from 192.168.1.66: bytes=32 time<1ms TTL=64
Reply from 192.168.1.66: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.1.66:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

All is well, however with adb:

C:\Users\XXX>adb shell "/system/bin/ping -c 1 192.168.1.66"
PING 192.168.1.66 (192.168.1.66) 56(84) bytes of data.
From 10.0.2.2: icmp_seq=1 Destination Port Unreachable

--- 192.168.1.66 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

Why is the destination not reachable from the android device and how to fix this? I tried with my AV off and the result the same.



Sources

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

Source: Stack Overflow

Solution Source