8

I'm following the first Ruby on Rails 3 tutorial from PeepCode and at around 27-29 minutes in, they have us start the Rails server. To the best of my knowledge, I have Rails (and Ruby) successfully installed.

When I run the command rails server (from Windows 7 Command Prompt per the instructions of the video), I get the message:

=> Booting WEBrick
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-12-02 18:37:57] INFO WEBrick 1.3.1
[2011-12-02 18:37:57] INFO ruby 1.9.3 (2011-10-30) [i386-mingw32]
[2011-12-02 18:37:57] INFO WEBrick::HTTPServer#start: pid=5584 port=3000

And it doesn't return to the prompt, indicating that it is running. Also, to me (and compared to the video), this looks like a successful message.

However, when I browse to the URL, http://0.0.0.0:3000, as directed by the video, I get an error (while the video opens to the default index page for Ruby). The error I get is:

Error 108 (net::ERR_ADDRESS_INVALID): Unknown error.

Since I'm using Google Chrome, it also says:

The webpage at http://0.0.0.0:3000/ might be temporarily down or it may have moved permanently to a new web address.

So, I was wondering how to fix this?

przemo_li
  • 3,932
  • 4
  • 35
  • 60
Bhaxy
  • 5,346
  • 10
  • 39
  • 41
  • 11
    since you're on windows, try 127.0.0.1:3000 or http://localhost:3000 – Jesse Wolgamott Dec 03 '11 at 02:51
  • @JesseWolgamott I tried that, and it works. Thank you! – Bhaxy Dec 03 '11 at 02:53
  • 3
    That is not sindows ;) specific. 127.0.0.1 is local host regardless of OS – Michael Durrant Dec 03 '11 at 03:24
  • 1
    @MichaelDurrant, that is true, but you can still connect to 0.0.0.0 on Mac and Linux, but you can't on Windows. I honestly did not know that you could connect to that address... I thought it was only to signify that is was bound to all addresses. – Sean Hill Dec 03 '11 at 06:26
  • Surprised the tutorial tells you to connect to 0.0.0.0, and surprised that it even works on any OS. It's rare that I think Windows does something right that Linux gets wrong. – Jim Stewart Apr 29 '13 at 23:09
  • On Windows DO NOT open at 127.0.0.1 or localhost IF your site is being accessed from outside – Andre Figueiredo Apr 24 '15 at 15:50

2 Answers2

13

0.0.0.0 is the ip address that Webrick is binding to. It means 'listen on all interfaces'. In other words, you can connect to this application from the internal address (localhost or 127.0.0.1) as well as the external address on the network (192.168.1.x or 10.0.10.x or a domain name that resolves to an address this machine has on the network). The server doesn't care where the request comes from.

If, however, you started rails server with the '-b' or '--binding' option and told the server to bind to 127.0.0.1, the server would not respond to requests to the external interface. You could still use 127.0.0.1 or localhost but you could not connect to this server using it's external ip address locally or from another machine.

Going to http:// 0.0.0.0:3000 works on my Linux system and most likely the screencast you were watching was using a mac which would also work. My guess is that 0.0.0.0 isn't supported on Windows.

Just use localhost if you are on the box or the ip address of the box if you are accessing it from another machine. That is what I do, even when I'm running a machine that understands 0.0.0.0.

Matt Hulse
  • 5,496
  • 4
  • 29
  • 37
3

You can start the server with this command:

rails server -b localhost

But as a lazy typist, in my .bash_aliases, I have this alias

alias rs='r s -b localhost'

With the alias, I can start the server with just:

rs
Marek Příhoda
  • 11,108
  • 3
  • 39
  • 53
  • Just to clarify, binding to localhost means that you can only access the site from the local machine. If you are doing a tutorial, or you don't want others to be able to hit your site, this is what you want. Otherwise, just leave the default binding and use http://localhost:3000 to access your app. – Matt Hulse Sep 11 '15 at 21:42