I installed ubuntu server inside a virtual box(11.04), then i configured apache.

Inside virtual box setting, i made a port forwarding from port 80(host) to 80(guest), i open my web browser on my host, and i go to http://localhost DON'T work, but if i go to http://localhost:1080, it work, but i didn't make a port forwarding from 1080 to 80, i have no 1080 in my configuration, what i want to know is why it does this?

I know that port 80 won't work until i launch the virtualbox as root, but what i don't know is why does it actually transform the port 80 to 1080 when it could just not work... is there something in virtualbox that see when its not root and transform address below 1024 to something else?


The VirtualBox manual says:

Forwarding host ports < 1024 impossible:

On Unix-based hosts (e.g. Linux, Solaris, Mac OS X) it is not possible to bind to ports below 1024 from applications that are not run by root. As a result, if you try to configure such a port forwarding, the VM will refuse to start.

I guess this is the reason for getting port 80 forwarded properly when the host was run as a root user. Anyway I am not sure why the port is changing automatically from 80 to 1080.

| improve this answer | |

There is a nice section explaining port forwarding with NAT on Virtualbox here:


I am not sure why your are seeing the behavior you are, can you post your configuration ?

The other (potential) solution is to use bridged networking. Personally I find bridged networking is easier to configure. If I feel I need a firewall, I configure it from the guest. You can easily limit port 80 to your host or lan with ufw.

sudo ufw enable
sudo ufw default deny
# change "" to your host
sudo ufw allow proto tcp from to any port 22
# Or for you LAN
sudo ufw allow proto tcp from to any port 80

You can change "any" to your IP if you wish.

| improve this answer | |
  • I already have read that page, but i have nothing configured for 1080, and i want to know why it 80 become 1080 when its not configured... – user1115057 Jan 14 '12 at 22:11
  • I can not tell much without additional information. Please post your configuration information, the commands you used, or screenshot. – Panther Jan 14 '12 at 22:20
  • virtualbox->network->portforwarding: RULE1 UDP "" "80" "" "80" RULE2 TCP "80" "" "80" the empty field mean any IP, so no 1080... i open up my web browser in my host, and i have to type localhost:1080, else it don't work – user1115057 Jan 14 '12 at 22:28
  • Did you try deleting that entry and running sudo VBoxManage modifyvm "Your VM name" --natpf1 "guesthttp,tcp,,80,,80" ? – Panther Jan 14 '12 at 22:36
  • i just finished transferring my virtual machine to root folder, now running from root, if i type localhost:1080, not working anymore, only port 80... strange behavior when not working with root privilege, maybe every program trying to use port 80 when not root are automatically remapped to port 1080... – user1115057 Jan 14 '12 at 22:50

I'm able to forward the ports by running VirtualBox as root. This restriction is just an OS thing, not really anything with VirtualBox itself.

Just open VirtualBox with sudo:

sudo /path/to/VirtualBox

Then the OS will allow you to use ports below 1024, which, of course you should do responsibly :)

| improve this answer | |
  • I've only tested with Ubuntu as the guest in this example. Presumably it will also work as a host. – syvex Jul 1 '15 at 21:20

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.