I've been working on getting setup with Vagrant using a VirtualBox base box, and would like to forward ports between my guest (Ubuntu 12.04) and my host (Windows 7) for accessing the apache2 server which will be running on the guest.

The problem I'm running into is that when I try to forward between port 80 on the guest and port 80 on the host (or even 8080) Vagrant will complain and alert me to the fact that the forward port "... is already in use on the host machine."

It isn't.

Running a netstat -a shows that nothing is connected or using port 80 (or even 8080). After some experimentation I found that apparently the free version of Avast! which I am using is blocking the forwarded ports. Not all of Avast! is to blame though, just their Web Shield.

With Avast! Web Shield turned off, using the below configuration file works flawlessly when booting up the VM, with it on... well therein lies the problem.

I want to try and find a solution that allows me to use Vagrant without having to compromise settings on an anti-virus if at all possible, or at the very least have a solution that doesn't have a ton of caveats. The intent is to use Vagrant as a means of simplifying development setup and not over complicating it.

For reference here is my Vagrantfile:


Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.box = "precise32"
  config.vm.box_url = "http://files.vagrantup.com/precise32.box"

  config.vm.network :forwarded_port, guest: 80, host: 80

  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--memory", "1024"]


I have tried private networks, public networks, etc. but I may be configuring them incorrectly.

Author's Note: This question may have been asked and answered already by someone else, and if it has, I apologize. Everything I've found so far doesn't seem to fit as a solution, I think part of the problem is I'm not sure I know the proper question to ask in order to find the correct solution. If there is an existing solution for this, please, by all means link it!

  • well, if it has been asked by somebody else, I hope that if anybody closes it they add a comment linking to the duplicate. but I doubt it has been asked. it looks like you thought about it
    – barlop
    Dec 20 '13 at 15:06
  • you will have to find a way to whitelist the port in webshield. if a program is blocking all forwarded ports, then that’s where both your problem and your fix are. Dec 20 '13 at 15:35

After updating avast! Free Antivirus to program version: 2014.9.0.2011 from 2014.9.0.2008 the problem seems to have resolved itself. It looks like there was a conflict the earlier 2014 release of Avast's antivirus. From their update history:

  • Fully rewritten WebShield so that it now doesn't work as a "transparent proxy" anymore, which should result in an overall improvement in stability and performance. It also allows to see and detect more threats
  • The Firewall component (in IS and Premier) has been made more compatible with other applications, such as Java and various VPN services

Alternatively, while it doesn't address the port forwarding issue directly, public and private netowrks both work but come with their own caveats:

  • Public networks acquire their own IP on the network and to access them it appears necessary to run an ifconfig in the guest to determine the assigned IP. This places greater burden on the individual using the VM as they have to take an extra step every time they spin the VM up to determine the IP of their server.
  • Private networks allow the assignment of a static IP address for private consumption between the host and guest. Maybe the best possible solution, barring port forwarding, with the exception that you need to choose the IP to be used.
  • 1
    You can set up your virtual machines with two network adapters, one host-only and the other one NAT. See this question Apr 19 '16 at 18:43

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.