Richard Knop
Richard Knop

Reputation: 83697

vagrant cannot access webserver on localhost:8080

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

Upvotes: 2

Views: 10523

Answers (5)

Sweet Chilly Philly
Sweet Chilly Philly

Reputation: 3219

I have found a solution,

I have found that there is an issue with Apache + vagrant, and sometimes Apache won't start automatically.

Please try: sudo service apache2 start once logged in via ssh.

I was having issues with Vagrant and all the error messages indicated a networking problem, but in reality my Apache service just wasn't starting on vagrant up

Upvotes: 0

Mingyu
Mingyu

Reputation: 33359

You may run the following command to find out if any other process (such as Tomcat) is bind to port 8080:

lsof -i :8080

If so, that may cause the problem.

Upvotes: 0

Simon
Simon

Reputation: 181

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.

Upvotes: 9

AJ Meyghani
AJ Meyghani

Reputation: 4589

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

Upvotes: 1

bfitzpatrick
bfitzpatrick

Reputation: 1513

I recently set up a CentOS 6.4 box. My ports got all messed up because of iptables. I just disabled the service. It's in /sbin/sevices.

Upvotes: 0

Related Questions