traday
Posts: 7
Joined: Wed Mar 05, 2014 3:42 am

ssh connects fine but browser connection refused

Mon Mar 31, 2014 2:27 am

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?

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: ssh connects fine but browser connection refused

Mon Mar 31, 2014 3:21 am

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.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: ssh connects fine but browser connection refused

Mon Mar 31, 2014 4:53 am

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.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

traday
Posts: 7
Joined: Wed Mar 05, 2014 3:42 am

Re: ssh connects fine but browser connection refused

Mon Mar 31, 2014 11:26 am

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.

User avatar
DougieLawson
Posts: 36557
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: ssh connects fine but browser connection refused

Tue Apr 01, 2014 12:29 am

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.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

traday
Posts: 7
Joined: Wed Mar 05, 2014 3:42 am

Re: ssh connects fine but browser connection refused

Tue Apr 01, 2014 1:41 am

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.

Return to “Troubleshooting”