- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to access localhost from host machine
I run web server http://127.0.0.1:8000/ inside ubuntu VM. I can open page from browser in ubuntu machine.
But when I try to open from host(windows 10) machine, i got ERR_CONNECTION_REFUSED.
I disable firewall, change adapter settings NAT/Bridge, try all ip addresses from ipconfig command, but not help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
As long as you try to connect to http://localhost ... you won't be able to connect to anything other than your local host (it's in the name)
Your VM running on your host.. is technically another host and thus not accessible via localhost.
What you can do is to
a) put your VM in bridge network configuration.
You should then be able to connect to the VM via its IP address.
Eg. http://<ip-address>:8000 where <ip-address> is for example 192.168.10.1 (check the ip address of your VM and put the actual ip address instead) like http://192.168.10.1:8000
Be careful to not use https:// instead of http:// as in that case you have to be able to serve a correct certificate for that IP address!
b) put your VM in NAT mode and forward the port via virtual network config. (See menu -> Edit -> Virtual Network Editor -> Change Settings button -> OK -> Select NAT -> Click "NAT Settings" button -> Add Port Forwarding)
Please note that "connection refused" usually indicates that there's a firewall blocking access from outside and/or that your service is not binding to the external IP address.
Good luck!
--
Wil
| More info at vimalin.com | Twitter @wilva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, there is a difference between 127.0.0.1 (localhost) and 0.0.0.0, later is used to allow "outside connection", so try 0.0.0.0:8000