Simon
Simon

Reputation: 751

Vagrant and Rails server: cannot connect to localhost

I'm trying to run a Rails app from my Ubuntu 12.04 64-bit virtual machine on Vagrant. Either running rails server or rails server -b 0.0.0.0 works, but in both cases when I try to reach localhost:3000 or 0.0.0.0:3000 from my local Windows 10 machine, it says ERR_CONNECTION_REFUSED.

I also put this line in the Vagrantfile:

config.vm.network "forwarded_port", guest: 3000, host: 3000

which should theoretically allow port forwarding on 3000, but when I run netstat -ntlp I get:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:50891           0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp6       0      0 :::111                  :::*                    LISTEN      -
tcp6       0      0 :::22                   :::*                    LISTEN      -
tcp6       0      0 :::36063                :::*                    LISTEN      -

so somehow my Vagrant machine is not listening to port 3000 anyway.

I also tried to vagrant reload, to no avail. Rails version is 5.0.1.

Where am I failing? Thanks in advance.

Upvotes: 1

Views: 1014

Answers (1)

Simon
Simon

Reputation: 751

Solved. The line in the Vagrantfile must be:

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

so with a colon instead of quotes.

Upvotes: 3

Related Questions