I know I can access the host's localhost using However, what I need is to to be able to type "localhost" in my VirtualBox Edge browser and for it to point to the localhost of my computer.

I have tried a couple thing with the host file, but no success yet. Is it even possible to do what I want?


  • 1
    What exactly are you trying to accomplish? What do you mean by "I can access the host"? Do you have a webserver running on the host? Aug 3 '19 at 22:58
  • localhost is It is local host, not another host...
    – cmak.fr
    Aug 4 '19 at 5:51
  • Exactly, I have a webserver that is running on the host. On the host, I can access this webserver with "localhost". On the VM, I want to also be able to access the webserver with "localhost". Aug 5 '19 at 15:42
  • No you don't as that would crash your system
    – Rinzwind
    Aug 5 '19 at 18:05
  • De rien.. >:-) Thanks for the acceptance and upvote, favour returned, question upvoted! ;-)
    – Fabby
    Aug 5 '19 at 20:13


Nope! Sorry! Cannot be done!

The long version:

As per RFC1122, section- the localhost is defined as:

(g) { 127, <any> }
Internal host loopback address. Addresses of this form MUST NOT appear outside a host.

Thus localhost cannot be re-mapped even at the /etc/host file level as the driver bypasses the host file for that particular item.

Having said the above, this is free software, so you have the source code of the kernel available to you but even if you would become a kernel developer and start creating a custom kernel that would allow you to do that, you'll run into a ton of routines everywhere which will assume localhost = hardcoded so that would just be extremely difficult (=years of work) but as you're talking Edge Browser you'd have to get Microsoft on your side as well and ... well ...

That's not going to happen! :-(

Sorry, neat idea but unfeasible...

  • 1
    That's too bad. My web pages on my host are all pointing to a localhost server. When I open the web pages in the VM, which are pointing to localhost, of course, it doesn't work. I need to change the "localhost" paths (HTTP requests to localhost:3030, which is my local server) of my webpages to "" every time I need to run the website on the VM. Great answer BTW. Thanks! Aug 5 '19 at 20:07
  • OTOH: just make your home page... ¯\_(ツ)_/¯
    – Fabby
    Aug 5 '19 at 20:15
  • 1
    Haha that would not work. is the web server that serves index.html. But there is javascript code on this page that makes HTTP requests to, so the code would need to be modified. Thanks for the effort though ;). Aug 5 '19 at 20:55

You can't change what localhost alone means, but the question isn't really about remapping localhost, but about getting http://localhost:80 to load the Host OS's port 80. This is certainly possible!

In the below examples, the host's LAN ip is – change this if yours is different:

If the guest is Windows, you can use netsh portproxy. Run cmd.exe as administrator, then type

netsh interface portproxy add v4tov4 listenport=80 listenaddress= connectaddress= connectport=80

and now if you browse http://localhost it'll pass on the request to port 80 on the host.

If netsh doesn't work for you / your guest isn't Windows, but you've got ssh access between guest and host, you can run this from the guest: ssh -L 80:localhost:80 and now from the guest if you browse http://localhost it'll pass on the request to port 80 on the host.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.