VirtualBox port forwarding not working with NAT adapter

It is not clear which guest OS you are using.

I have faced the same problem.

My host was MAC PC and guest was CentOS 7 on VirtualBox.
I enabled the NAT port forwarding from guest to host at VirtualBox level for both ssh port 22 and http port 80.

However I found that I could not connect to the Apache HTTP server on Centos 7 guest from my MAC PC host on http connection.

To fix it, I have to set the firewalld service to allow port 80 connections.


You've pointed guest ip in wrong manner it should be ip of guest (if you're statically assign ip address to guest) or leave it empty. Note you're pointed host ip as 127.0.0.1 it means that port you're forwarding will be accessible only from port (if it isn't what you're desired it should be empty as well).

VBoxManage modifyvm "win" --natpf1 ",tcp,,8081,,8081"

perhaps this is something you've wanted to do. (please look here for more details)


Paravirtualized Network* (virtio-net) is the key

  1. select your vm that you want for port forwarding.

    • NOTE: Make sure the vm is in stop mode.
  2. Select “Settings"

  3. Select “Network"
  4. Select any free Adapter. Lets say "Adapter 2"
  5. Enable "Enable Network Adapter"
  6. In Attached to dropdown, select "NAT"
  7. Select "Advanced"
  8. In Adapter Type: Select “Paravirtualized Network (virtio-net)” [ This is important ]
  9. Select “Port Forwarding"
  10. In Right hand part of the “port forwarding” dialog box, select “+"
  11. Provide the

    • Name: Anything you want. example for ssh, say “ssh"
    • Protocol: Type of protocol [ for ssh: TCP ]
    • Host IP: provide hostname from which host you want to connect to [ over here: 127.0.0.1 ]
    • Host Port: On what port of that Host you want to connect to remote port [ example: 60022 ]
    • Guest IP: Leave it Blank
    • Guest Port: To what port you want to connect from the above host. [ for ssh, the default 22 ]