vagrant cannot access webserver on localhost:8080

10,089

Solution 1

Have you checked your iptables?

It's a common mistake: when you use provisioning you also have to configure your iptables. (For puppet you have this module.) If you don't want to work with a firewall you can just do vagrant ssh followed by sudo service iptables stop.

Solution 2

What do you see when you go to your browser? Does it say Data not received or it never stops reloading? Do you get any messages in your browser? The server config file must be a bit messed up. Try reloading the server configuration, and restarting it.

Also, try changing the port number to something else. With the newer version of Vagrant, the syntex looks a bit different. So you have to do:

config.vm.forward_port 80, 2759

This is the config file that I use for one of my instances:

Vagrant::Config.run do |config|
  config.vm.box       = 'rails-dev-ready'
  config.vm.host_name = 'rails-dev-ready'

  config.vm.forward_port 5800, 5800
  config.vm.forward_port 1080, 1090
  config.vm.forward_port 80, 2759

  config.vm.provision :puppet,
    :manifests_path => 'puppet/manifests',
    :module_path    => 'puppet/modules'
config.vm.share_folder "sharedapps", "/home/vagrant/sharedapps", "sharedapps"

end
Share:
10,089
Richard Knop
Author by

Richard Knop

I'm a software engineer mostly working on backend from 2011. I have used various languages but has been mostly been writing Go code since 2014. In addition, I have been involved in lot of infra work and have experience with various public cloud platforms, Kubernetes, Terraform etc. For databases I have used lot of Postgres and MySQL but also Redis and other key value or document databases. Check some of my open source projects: https://github.com/RichardKnop/machinery https://github.com/RichardKnop/go-oauth2-server https://github.com/RichardKnop

Updated on July 13, 2022

Comments

  • Richard Knop
    Richard Knop almost 2 years

    I am running CentOS 6.4 through vagrant.

    I have put this line inside my Vagrantfile:

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

    Then I have installed nginx in the VM and verified it's working with:

    wget http://locahost/
    

    Works fine.

    But from my host machine (Macbook Air, Mountain Lion) when I go to:

    http://localhost:8080
    

    It times out. Did I miss any configuration in Vagrantfile?

    I have used this box:

    https://github.com/NREL/vagrant-boxes

    • cmur2
      cmur2 about 11 years
      Sounds ok, maybe there is some kind of firewall involved?
  • Ryre
    Ryre over 8 years
    I had to run this command as sudo in order to get everything.