Running Rails S with a fresh new app returns ERR_EMPTY_RESPONSE
Asked Answered
S

1

5

I am using Vagrant to start a Rails app, everything seems right but then, when I create a test app, run rails s and go to localhost:3000 I get a ERR_EMPTY_RESPONSE and nothing is loaded. I get the following output when running rails s:

vagrant@rails-dev-box:~/projects/NewAppName$ rails s
=> Booting WEBrick
=> Rails 4.2.3 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-08-20 11:45:45] INFO  WEBrick 1.3.1
[2015-08-20 11:45:45] INFO  ruby 2.2.1 (2015-02-26) [i686-linux]
[2015-08-20 11:45:45] INFO  WEBrick::HTTPServer#start: pid=12075 port=3000

I already ran rake db:create && rake db:migrate, and created a controller for the root. Anyone has an idea of what can be happening? Thank you.

Sparker answered 20/8, 2015 at 11:50 Comment(3)
What do you expect it to render?Caresa
@Caresa I expect to see the controller's action view that i set as a root in the routes file. Currently it has the default "Find me in app/views/home/index.html.erb"Sparker
Please add routes.rb and controller's code then.Caresa
P
13

It's in localhost on vagrant, so you can't connect it. Try rails s -b 0.0.0.0 and then connect to vagrant IP(192.168.50.4:3000, for example).

Peril answered 20/8, 2015 at 13:45 Comment(3)
As an extra, this happens because rails doesn't bind by default (since rails 4.2) to all IP addresses on the machine. as Igor said it is only binded to localhost on vagrant and in order to access the server through a custom ip the -b 0.0.0.0 is needed. Here is question related to this issue.Sparker
as variant, I can advise you using nginx to proxy your rails from localhost to external network. It will proxy the requests from :80 to :3000 or to socket of your serverPeril
You should merely be able to connect on localhost:3000 from the host machine after using -b 0.0.0.0. No need for 192.168.50.4 etc. But as Igor mentioned probably best just setting up nginxPaul

© 2022 - 2024 — McMap. All rights reserved.