0

I have issues connecting to the mean.io server after setting up a vagrant running CentOS7. I have port forwarding and disabled / opened firewall but still get no response on either wget or curl -v.

The following steps I have automated to get to where I am now:

git clone git@github.com:Scrier/Vagrant.git
cd Vagrant/mean
vagrant up

Here I get output with port forwarding setup:

==> default: Attempting graceful shutdown of VM...
==> default: Clearing any previously set forwarded ports...
==> default: Couldn't find Cheffile at ./Cheffile.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 3000 => 3000 (adapter 1)
    default: 35729 => 35729 (adapter 1)
    default: 80 => 8888 (adapter 1)
    default: 22 => 2222 (adapter 1)
...

Next steps is inside the Vagrant:

vagrant ssh
cd /vagrant
sudo ./install.sh
sudo npm install -g gulp
sudo npm install -g bower
sudo npm install -g mean-cli

The last 3 commands sometimes don't work complaining in later steps that some npm:s is owned by root. Not sure what triggers this.

Next I create a test project in /vagrant

mean init test

Then I try to run as either gulp (cd test && npm install && gulp) or server (node server)

The default application starts up nice and starts to listen on port 3000. I can curl on the vagrant and do wget on localhost with the server answering.

curl 'http://localhost:3000'
wget 'http://localhost:3000'

Doing this from outside the vagrant gives a lock and I cant find any more help on the net now after 3 days searching.

curl -v 'http://localhost:3000'
wget 'http://localhost:3000'

giving this output:

Andreass-MBP:~ andreasjoelsson$ wget 'http://localhost:3000'
--2015-04-21 20:50:30--  http://localhost:3000/
Resolving localhost... 127.0.0.1, ::1, fe80::1
Connecting to localhost|127.0.0.1|:3000... connected.
HTTP request sent, awaiting response... ^C

Andreass-MBP:~ andreasjoelsson$ curl -v 'http://localhost:3000'
* Rebuilt URL to: http://localhost:3000/
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.37.1
> Host: localhost:3000
> Accept: */*
>
^C

both stops on the response.

I have read about setting ip 0.0.0.0 instead of localhost for a similar problem running nodejs, I can't however find any configuration in mean for this.

Andreas
  • 539
  • 1
  • 5
  • 13

1 Answers1

1

So, after a long time banging my head against this I got it to work by trying a suggestion in this thread: Empty reply from server - can't connect to vagrant vm w/port forwarding

By changing 127.0.0.1 in /etc/hosts for localhost to 0.0.0.0 it starts working. Seems odd I have to go attack the /etc/hosts instead of a setting in mean.io, but I got it working so I will be quietly oblivious and happy that it works.

The following is a quick command to make it work.

sed -i -E "s/127.0.0.1(.*)/0.0.0.0\1 # Replaced 127.0.0.1 to work with Vagrant external access./" /etc/hosts

Might need to run it as root.

Community
  • 1
  • 1
Andreas
  • 539
  • 1
  • 5
  • 13