Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Building Web Apps with Sinatra Your First Sinatra App Your First App

MaryAnn Eleanya
MaryAnn Eleanya
8,626 Points

I keep receiving the following messages every time I try to log on to localhost:4567 using Sinatra.

This site can’t be reached localhost refused to connect. Search Google for localhost 4567 ERR_CONNECTION_REFUSED

this might be basic, but are you using http://localhost:4567? some browser clients add the http:// automatically, others don't.

secondly, do you have a firewall currently in place?

MaryAnn Eleanya
MaryAnn Eleanya
8,626 Points

Yes, that is the link I am using. Also I disabled my firewall but its still not working.

Also this is the message I receive when I run the program on ruby.

"treehouse:~/workspace$ ruby produce.rb
[2018-03-12 23:00:28] INFO WEBrick 1.3.1
[2018-03-12 23:00:28] INFO ruby 2.3.3 (2016-11-21) [x86_64-linux]
== Sinatra (v1.4.7) has taken the stage on 4567 for development with backup from WEBrick
[2018-03-12 23:00:28] INFO WEBrick::HTTPServer#start: pid=187 port=4567 "

alexx1000
alexx1000
16,187 Points

Hello everybody! I've followed all the instructions to install Sinatra to my pc and run http://localhost:/4567/apple and I still keep receiving the same message: "This site can’t be reached localhost refused to connect. Search Google for localhost 4567 ERR_CONNECTION_REFUSED"

This is the link that I am using for reference http://sinatrarb.com/ as it seems to have the latest commits and updates.

Can somebody help me? Workpaces runs ok no problem but I want to build and run my Sinatra app in my computer and localhost. I will really appreciate your help! Thank you so much! Happy coding! ;)

2 Answers

are you trying to navigate to localhost in a browser, or clicking the eyeball in the top right corner of the workspaces screen? from what I remember, workspaces doesn't output ruby to your machine to preview through workspaces, so you have to use that eyeball.

MaryAnn Eleanya
MaryAnn Eleanya
8,626 Points

Hi, Yes, I am trying to access it through a local browser.

Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

Hi, MaryAnn Eleanya ,

Because your pasted shell prompt includes treehouse:~/workspace, I can see that you have written your code in Workspaces. But http://localhost:4567 is a URL that you will only want to use if you are running a Sinatra app using a Ruby interpreter that you installed on your personal computer, not Workspaces.

The "Your First App" video includes directions both for running a Sinatra app on your personal computer, and for running it within Workspaces. It's important not to confuse the two. The Workspaces directions begin at 5:03 in the video. Follow those, and you should be able to connect.