Using 10.0.2.2 to Reach a Host Proxy from a VirtualBox NAT Guest
Interpret VirtualBox's NAT host alias in its actual network context when choosing a proxy address.
A Vagrant example uses 10.0.2.2:3128. You copy it to a laptop browser and the proxy is unreachable. The number was not a universal address for the host machine.
In VirtualBox's usual first NAT-adapter setup, 10.0.2.2 has a special guest-to-host role. Its meaning depends on that virtual networking arrangement. Another hypervisor, a different adapter mode or another network namespace can require another address.
| Where the client runs | What to identify |
|---|---|
| Host itself | A host-reachable listener, perhaps its loopback |
| VirtualBox NAT guest | The documented host-access mapping for that adapter |
| Bridged guest or another LAN machine | A reachable host address and permitted listener |
| Container inside the guest | Another network boundary and its route to the proxy |
A guest's 127.0.0.1 normally names the guest, not the host. Conversely, the special NAT mapping must not be generalized to every place the configuration might be read.
After choosing the address, check the listener and access policy. A host service bound only where a bridged guest cannot reach it will not become reachable through a different URL spelling. Broadening the bind should be a deliberate access decision, with matching firewall restrictions.
Keep the client location attached to configuration examples. “Proxy is on the host” is incomplete when several hosts and guests share the same setup.