Page 1 of 1

ssh connects fine but browser connection refused

Posted: Mon Mar 31, 2014 2:27 am
by traday
I have ruby (2.0.0-p451) and sinatra (1.4.4) running (listening on 4567) on my pi and if I curl locally

Code: Select all

curl localhost:4567
I get 'hello world' as expected.
If I curl from another machine on the network, I get "curl: (7) Failed connect to 10.0.0.8:4567; Connection refused"
I actually have two interfaces, eth0 and wlan0 and no matter which I use, I get the same message (with the IP address different)

I am running raspbian "wheezy" as of 2014-01-07
My guess is that it has something to do with the way I have setup the interfaces.
cat /etc/network/interfaces

Code: Select all

auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
   wpa-scan-ssid 1
   wpa-ap-scan 1
   wpa-key-mgmt WPA-PSK
   wpa-proto RSN WPA
   wpa-pairwise CCMP TKIP
   wpa-group CCMP TKIP
   wpa-ssid "redacted"
   wpa-psk "redacted"
iface default inet dhcp
cat /etc/default/ifplugd

Code: Select all

INTERFACES=""
HOTPLUG_INTERFACES="wlan0 eth0"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"
netstat -tln

Code: Select all

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:4567          0.0.0.0:*               LISTEN
Thoughts?

Re: ssh connects fine but browser connection refused

Posted: Mon Mar 31, 2014 3:21 am
by Richard-TX
localhost == 127.0.0.1 any test with localhost as a dest is a pointless test.

You should test to your pi using whatever ip is assigned to eth0 and the wlan0 addresses.

netstat -rn would have been more telling.

Re: ssh connects fine but browser connection refused

Posted: Mon Mar 31, 2014 4:53 am
by SirLagz
Richard-TX wrote:localhost == 127.0.0.1 any test with localhost as a dest is a pointless test.

You should test to your pi using whatever ip is assigned to eth0 and the wlan0 addresses.

netstat -rn would have been more telling.
That's not quite true, it proves the server is running properly.

The issue is that the server is not listening on eth0 or wlan0. It's only listening on the loopback interface.
Once the server is configured to listen on eth0 or wlan0, then you'll be able to access it using a web browser.

Re: ssh connects fine but browser connection refused

Posted: Mon Mar 31, 2014 11:26 am
by traday
SirLagz wrote: The issue is that the server is not listening on eth0 or wlan0. It's only listening on the loopback interface.
Once the server is configured to listen on eth0 or wlan0, then you'll be able to access it using a web browser.
Richard, that makes sense. Any thoughts on how I get anything to listen on the proper interfaces? When I do something similar on my Mac (start sinatra), it automatically listens on the eth0 interface, not on the loopback.

Re: ssh connects fine but browser connection refused

Posted: Tue Apr 01, 2014 12:29 am
by DougieLawson
You need to update sinatra
set :bind, '0.0.0.0'
or -o "0.0.0.0"

It's currently got bind set to localhost.

Re: ssh connects fine but browser connection refused

Posted: Tue Apr 01, 2014 1:41 am
by traday
DougieLawson wrote:You need to update sinatra
set :bind, '0.0.0.0'
or -o "0.0.0.0"

It's currently got bind set to localhost.
Thank you, and you beat me to the punch. I just put
set :bind, '10.0.0.8'
in my sinatra file and it worked great.
Cheers.