1

This question already has an answer here:

I have a catalyst server running on a VM.

[info] Hello powered by Catalyst 5.90103                                                                                                                                             
HTTP::Server::PSGI: Accepting connections at http://0:3009/

And connecting within the VM

vagrant@precise32:/var/log/apache2$ curl 'http://localhost:3009'
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
etc ...

The port seems to be listening

vagrant@precise32:/var/log/apache2$ netstat -an | grep "LISTEN "
tcp        0      0 0.0.0.0:36300           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:80              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:3009            0.0.0.0:*               LISTEN     

Connecting remotely I can see port 80 but not 3009

curl 'http://localhost:80'
curl: (52) Empty reply from server
curl 'http://localhost:3009'
curl: (7) Failed to connect to localhost port 3009: Connection refused

I've seen similar threads but nothing has helped. This is iptables

vagrant@precise32:/var/log/apache2$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

And the firewall is turned off

vagrant@precise32:/var/log/apache2$ sudo ufw status  
Status: inactive

I'm very new at VM, I'm not sure if this is a hosts problem, an apache problem or a cataylst problem. I did try running a python server and couldn't connect to that either. All advice is much appreciated. Thanks

EDIT - I've looked at similar posts, the general solutions there are not listening ports or firewall. I don't think either applies here.

marked as duplicate by Iain, Dave M, mdpc, MadHatter, Ward Dec 6 '15 at 19:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Thanks, I've looked at the post but it only gives advice on if the port isn't listening or the firewall is on, which doesn't apply to me as far as I can tell. – Geo1986 Dec 3 '15 at 21:38
  • 1
    @Geo1986, How are you supposed to connect remotely using localhost? Doesn`t the vm has an ip address to access it remotely? – Diamant Dec 3 '15 at 21:44
  • I used vagrant to set it up - docs.vagrantup.com/v2/getting-started/networking.html. In this case I'm using curl '127.0.0.1:3009'. I could be totally in the wrong direction here. – Geo1986 Dec 3 '15 at 21:49
  • There could be a firewall between you and the box that is causng a problem. Did you use tcp dump to analyse it ? – Iain Dec 3 '15 at 21:49
  • When you are external to the vagrant box, localhost is the loopback address of the external device. Unless you have taken steps to forward the extrenalLoopbackAddress:3009 to the vagrant box then nothing is listening and you will get a connection refused message. – Iain Dec 3 '15 at 21:58
3

You are trying to access the app on vagrant box listening on port 3009, using address localhost remotely. For this to work, you need to setup the port forwarding correctly as mentioned in the vagrant doc: https://docs.vagrantup.com/v2/getting-started/networking.html

Check and make sure, it is setup correctly and that the request on http://localhost:3009 is forwarded to the vagrant box. You should also make sure that your local firewall is not blocking connection to the port.

  • got it! Needed to add to the VagrantFile config.vm.network :forwarded_port, guest: 3009, host: 3009 Thank you! – Geo1986 Dec 3 '15 at 22:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.