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.
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
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
Make sure you run rake db:create before launching rails s.
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.
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
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.
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.
check your /etc/hosts file..is ip 0.0.0.0 or localhost pointing to some other address.
for me...I was behind a proxy at work and had to do rails s -b 0.0.0.0 -p 3000
Related
I have a Rails application that uses subdomains (legacy application, I've been wanting to change that, not yet). I deployed my app to Heroku and I've started to test Puma because it's the recommended choice for Heroku and the default in the upcoming release of Rails. When I used WEBrick (locally) I was able to test my subdomains using a DNS record that pointed to 127.0.0.1 such as vcap.me, specifically http://vcap.me:3000/ would point to my app and http://abcde.vcap.me:3000/ will correctly set the subdomian to "abcde".
Simply adding gem 'puma' to my Gemfile and runnning bundle, causes rails server to start Puma. Except none of the test domains work: http://localhost:3000/ works, but not http://vcap.me:3000/ or http://lvh.me:3000/
Chrome simply says:
"This webpage is not available
ERR_CONNECTION_REFUSED"
Firefox:
"Unable to connect
Firefox can't establish a connection to the server at vcap.me:3000.
..."
I haven't found a cause/solution, but I suspect it has to do with non HTTP TCP requests supported by Puma, except right know, I'm simply trying a HTTP request through the browser.
Just for the curious, if you haven't heard about vcap.me and similar domains, it's simply a DNS record that points to localhost:
$ dig vcap.me
...
vcap.me. 3048 IN A 127.0.0.1
...
$ dig a.vcap.me
...
a.vcap.me. 3600 IN A 127.0.0.1
...
I feel ashamed, #maxd posted a solution to a very similar question: https://stackoverflow.com/a/28745407/637094 and it works. I still don't understand why I need to bind to vcap.me and I didn't before when I used WEBrick.
rails server -p 3000 -b vcap.me
I'll leave the question open, so maybe someone can expand and we all get a better picture of what's going on
This was issue #782 in the Puma server that was solved on July 18, 2016 here.
Your use of domains like vcap.me was not the issue. That domain be resolved to 127.0.0.1 by the DNS server. The issue was, before it was fixed, that on some systems Puma would by default bind only to the IPv6 resolution of localhost, i.e. ::1. Since vcap.me does not provide a IPv6 resolution, you could not reach Puma by calling http://vcap.me:3000/.
Your observation that rails server -p 3000 -b vcap.me solved the issue is because that is equivalent to rails server -p 3000 -b 127.0.0.1. After that, the server's address matched the IPv4-only name resolution of vcap.me.
Anyway, it's an issue of the past. Now by default, Puma binds to both the IPv4 and IPv6 resolutions of localhost.
I'm fairly new to Rails and VPS. I created a SSH tunnel and managed to install Ruby/Rails, then I created a simple scaffolding app to play around. One question now coming up is, how I can access the running WEBrick server via my browser? I tried the IP of my VPS and added XXX.XXX.XXX.XX:3000 as the port. But for some reason it does not work. Any idea? Thanks
Try port 80 as 3000 can be quite sensitive to firewalls and certain ISP's
I'm running a Rails application on a Mac Mini server machine (with Webrick, running ruby 1.9.2 using rvm). It works fine when I run it locally on my MacBook, and it was working before I reinstalled rvm, but now whenever I try to access it from a browser on my local machine, it simply hangs and doesn't respond.
If I do a curl http://0.0.0.0:3000 on my server, though, I get the webpage back fine.
I created a fresh Rails app just to double-check it wasn't a problem with my app, and I get the same problem. I also get the problem with Mongrel, and if I try running a bare Sinatra app with Thin.
It sounds like the same problem documented here: Webrick is very slow to respond. How to speed it up?, but I tried modifying my config.rb file to use :DoNotReverseLookup => true, and it didn't help.
Any ideas?
I don't think the issue is related to Rails or your dispatcher. It looks like the OS firewall is blocking ingoing requests to port 3000. Did you try to allow all ingoing connections from your System Preferences ?
When I tried to follow the official "Getting Started" Ruby on Rails tutorial, it went wrong very quickly. Basically it said :
…navigate to http://localhost:3000. You should see Rails’ default information page.
But when I follow the instructions, I get
=> Rails 2.3.4 application starting on http://0.0.0.0:3000
After trying both addresses, I know that they point to the same thing, but can someone explain to me why Ruby on Rails uses http://0.0.0.0:3000 instead of http://localhost:3000?
Is there a way to always have the WEBrick server use localhost?
Localhost means quite literally "your local host", usually identified by 127.0.0.1 and all traffic to that address is routed via a loopback interface. If your Web server is listening for connections on 127.0.0.1, this means that it only accepts requests coming from the same host.
0.0.0.0 means that Rails is listening on all interfaces, not just the loopback interface.
0.0.0.0 means all interfaces. Including 127.0.0.1 a.k.a. localhost.
Just so everyone knows, my firefox browser correctly displays the locally hosted server if I access
http://localhost:3000/
but it does NOT display when I attempt to access
http://0.0.0.0:3000/
as recommended by Ruby. Clearly, in some sense, they are not equivalent.
I'm on Windows btw.
If you want localhost, one quick way is to specify the binding rails s -blocalhost (and the port with -pNNNN, more options with rails s --help).
My server started running by default on localhost for reasons to be investigated. As a result lvh.me stopped working, preventing me from specifying subdomains (eg: www.lvh.me:3000).
I "solved" this specifying the binding:
rails s -b0.0.0.0 # will work with lvh.me
Rails 4.1 Warning Message.
FYI, on Rails 4.1 you will get a warning message on boot that looks like this:
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
This indicates that binding to 0.0.0.0 is not recommended and instead you should use 127.0.0.1.
In Rails 4.2+ the Rails server default binding is to localhost instead of 0.0.0.0 or even 127.0.0.1.
For those of us using Nitrous.io virtual server envrionment for development, I believe we have to bind to 0.0.0.0 as there is no localhost per se.
Restarted the os works for me. (On Mac v 10.12)
I am trying to learn Ruby on Rails, I have followed the instructions from this page to get rails installed on my PC.
I am also trying to follow this webcast to try and learn the language and framework. Everything is working so far, apart from the fact that I cannot access
http://localhost:3000
http://0.0.0.0:3000
http://127.0.0.1:3000, or
http://<actual IP address>:3000
locally. If I try the from another PC on my network then it works great. I have tried in Chrome, Firefox and IE7 but none work.
Has anyone else had this problem?
EDIT: Typical!! It's started working now. I have no idea why, I am typing the exact same address in to the address bar and it now works. But only if I use http://127.0.0.1:3000, localhost doesn't work. I do run IIS ASP.NET/ASP websites on this machine, and they work fine with localhost.
EDIT 2: If I trying pinging localhost it actually says
Reply from ::1: time<1ms
0.0.0.0 yields...
PING: transmit failed, error code 1214
only 127.0.0.1 seems to work. I did have IPv6 turned on, so I've disabled that and will try again tomorrow to see if a reboot helps.
I had this issue as well with Vagrant. The secret is to run
bin/rails server -b 0.0.0.0
What 0.0.0.0 means is to listen to all interfaces, not just on localhost. The alternative is to SSH into the vagrant machine with a SOCKS proxy.
ssh -C -D 8080 vagrant#localhost
Open up your Internet explorer proxy settings and set the SOCKS v5 proxy to port 8080.
In order to access http://localhost:3000 you need to run the local Rails server in a terminal window:
$ rails server
This is described in this section of the Rails Tutorial book.
Note: I am the presenter of the screencasts in question.
Can you telnet to the port? Try:
telnet localhost 3000
That should tell you if the ports unavailable at the TCP level, or whether something's going on at the HTTP level.
Ping might not work if ICMP is disabled, which could be completely unrelated to your issue.
Also, try looking in your hosts file for any redirections:
c:\Windows\System32\drivers\etc\hosts
One way is to do the simple
rails s
Another (more specifically) is
rails start localhost 0.0.0.0
or
rails start 0.0.0.0
another way is
rails s 0.0.0.0
all of these works
I had an epic issue with my System Path (Environmental Variable) not being set properly.
Simple copy paste job, unplugged the 1 week stalled Ruby installation.
Control Panel > System > Advanced tab > Environment Variables > System variables > Path... Edit...
Make sure it contains these paths (among others)...
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
I had your same identical problem. You have simply to run
$ rails server
from inside the folder of your application, not outside...so, if you have your application in
C:\Sites\myapp\blog
and blog is the folder where live your app, the command has to be prompted from here. Launching it from myapp folder won't work.
Are you possibly using a proxy but haven't listed localhost as proxy exception?
Have you tried disabling your firewall? They can cause pesky problems at times.