Macos – How to setup VirtualBox port forwarding on Mac OS X to Ubuntu 16.04

macosvirtual machinevirtualbox

Everything I've read so far makes port forwarding sound like a snap but I must be missing some magic piece. Here's what I'm doing:

  1. Host OS = Mac OS X
  2. Guest OS = Ubuntu 16.04 Server
  3. Run gunicorn web server on port 8000 on Guest OS
  4. Forward port 8000 on Host (OS X) to 8000 on Guest (Ubuntu)

This is a fresh VM with no services configured and I've verified ufw is disabled. I can view 127.0.0.1:8000 within the guest OS but not from the host OS.

I am assuming my VirtualBox installation is simply missing a key step rather than the settings which look quite straightforward. Can anyone guide me the in the correct direction?

Port Forwarding 8000 from Mac OS X host to Ubuntu 16.04 guest

Best Answer

It looks like the application you are running is binding to 127.0.0.1, which means it will only accept connections from the localhost. Port forwarding is considered a remote connection. You will need to figure out how to configure your application to accept remote connections or bind to either your VM's IP address or 0.0.0.0.

Related Question