Vagrant: port forwarding doesn't work

Created on 15 Jun 2015  路  2Comments  路  Source: hashicorp/vagrant

My config:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "centos"
  config.vm.network "forwarded_port", guest: 8080, host: 5555
  # config.vm.network "private_network", ip: "192.168.1.10"
  # config.vm.network "public_network"
  config.vm.synced_folder "./", "/Users/alexey/projects/prjct"
end

running

vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 8080 => 5555 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /Users/alexey/projects/prjct
    default: /Users/alexey/projects/prjct => /Users/alexey/projects/prjct
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.

then on vagrant box

cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core) 
sudo service iptables stop
Redirecting to /bin/systemctl stop  iptables.service
Failed to issue method call: Unit iptables.service not loaded.
python -m SimpleHTTPServer 8080
Serving HTTP on 0.0.0.0 port 8080 ...

opened another ssh connection

 curl -I http://localhost:8080
HTTP/1.0 200 OK
Server: SimpleHTTP/0.6 Python/2.7.5
Date: Mon, 15 Jun 2015 10:15:55 GMT
Content-type: text/html; charset=UTF-8
Content-Length: 444

on my machine

curl -I http://localhost:5555
curl: (7) Failed to connect to localhost port 5555: Connection refused

What I'm doing wrong?

vagrant -v
Vagrant 1.7.2
ruby --version
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
sw_vers -productVersion 
10.10.1

virtualbox is 4.3.26 r98988

A lot of thanks for the great product!

Most helpful comment

solved via

config.vm.network "forwarded_port", guest: 8080, host: 5555, host_ip: "127.0.0.1"

All 2 comments

solved via

config.vm.network "forwarded_port", guest: 8080, host: 5555, host_ip: "127.0.0.1"

do not forget to write
systemctl stop firewalld
before after all

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luispabon picture luispabon  路  3Comments

janw-me picture janw-me  路  3Comments

hesco picture hesco  路  3Comments

bbaassssiiee picture bbaassssiiee  路  3Comments

RobertSwirsky picture RobertSwirsky  路  3Comments