Reputation: 325
I am learning Ruby on Rails with railstutorial.org I had set everything up and working fine from Chapter 1. However, all of a sudden my next app has an issue.
I run "rails server"
=> Booting WEBrick
=> Rails 3.2.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-11-15 00:45:08] INFO WEBrick 1.3.1
[2012-11-15 00:45:08] INFO ruby 1.9.3 (2012-11-10) [x86_64-linux]
[2012-11-15 00:45:08] INFO WEBrick::HTTPServer#start: pid=2752 port=3000
Seems to be working fine, just like with my previous app.
However, I try connecting to localhost:3000 , 0.0.0.0:3000 , 127.0.0.1:3000 on various browsers and they all cannot establish a connection to the server.
Some things to note:
-I was able to connect to localhost just a while ago--it just seems like it suddenly stopped working out of the blue.
-My first app was working perfectly fine, but now it doesn't work for my first app either.
-I don't have firewalls blocking the port, and my hosts file is not the problem.
-I am on Ubuntu 12.10
I almost always find solutions via search, but not this time.. so I need some help please. It's very frustrating as I feel like it's a simple problem that I spent way too long being stuck on.
Thank you.
Upvotes: 18
Views: 50752
Reputation: 1100
I'm using rails 5.0.0.beta3 and was running into this issue. @andrewleung's answer helped me a lot.
It seems like Rails default binding address is messed up on my computer (macOS 10.11.6) ; on some others, it works fine.
The simple solution is just to use rails server -b 127.0.0.1
. You can then access your localhost:3000
.
My guess here is (hinted from https://serverfault.com/a/544188) that localhost
binding is messed up on my computer whereas 127.0.0.1
is more specific.
Upvotes: 5
Reputation: 140
for me...I was behind a proxy at work and had to do rails s -b 0.0.0.0 -p 3000
Upvotes: 0
Reputation: 227
I had the same issues and i realized it was in the config/environment/production.rb
file where config.assets.compile = false
must be changed to config.assets.compile = true
However this might in a way render some javascript and sass elements unworking
Upvotes: 1
Reputation: 4427
check your /etc/hosts file..is ip 0.0.0.0 or localhost pointing to some other address.
Upvotes: 0
Reputation: 3301
I run into the same issue. It turned out that browser-sync is also running on localhost:3000.
Due to some Rails developer would use browser-sync to test out the front end scripts quickly, I think that could be a popular reason that port 3000 is used.
Upvotes: 0
Reputation: 39695
The issue that it turned out I was having was that my VM had run out of hard drive space and there wasn't even enough left to create the server.pid file. For some reason though, it wasn't throwing an error for this, as the file was being created, but was left blank.
Upvotes: 0
Reputation: 572
with rails 4.2.0, the server binds to localhost
by default, instead of 0.0.0.0
. When working with a rails in a virtual box, accessing the server from the host computer, the binding address needs to be 0.0.0.0
Start rails server with -b0.0.0.0
to make the rails server accessible from the host computer/browser.
http://guides.rubyonrails.org/4_2_release_notes.html#default-host-for-rails-server https://github.com/samuelkadolph/unicorn-rails/issues/12#issuecomment-60875268
Upvotes: 15
Reputation: 2289
Try running it in some other port like say 3001 as:
rails server -p 3001
If its working than than try it again on 3000 as the command above.
I thing some other software is using your 3000 port that's why its not responding.
Or for some advanced things see here
Upvotes: 15