Search code examples
ruby-on-railswebrick

WEBrick doesn't make things appear in the web browser with Rails 4.2.0 version


I've been using Amazon EC2 for my development exercises.(I'm not that experienced and learning now by myself) Usually, I could do my tasks with ruby version 2.0.0 and rails 4.0.1 in Amazon linux EC2. My first tutorial instructed me to do exercises with those versions.(for ruby and rails) There was no problem when I ran rails server, which made WEBrick works and I could see my works on web browsers.

Few days ago I knew Ruby on Rails Tutorial, so I wanted to learn rails with Ruby on Rails Tutorial(by Michael Hartl). So I made another Amazon EC2 and accessed with putty and downloaded what I need. Here's what I have done.

#for rvm
gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable

#with rvm
source .bash_profile
rvm install ruby

#and for rails
gem install rails -v 4.2.0.rc3 --no-ri --no-rdoc

#then I made my sample_app
rails new sample_app --skip-bundle

#made 'therubyracer' works with deleting the "#" sign
#and with "sudo yum install sqlite-devel"(I don't know what this part means but server said I need it, so I just did)

then I ran my WEBrick with rails server

=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-12-28 05:54:29] INFO  WEBrick 1.3.1
[2014-12-28 05:54:29] INFO  ruby 2.0.0 (2014-11-13) [x86_64-linux]
[2014-12-28 05:54:29] INFO  WEBrick::HTTPServer#start: pid=25353 port=3000

this very Usual comments were coming out but I couldn't access my server with browser through my "IP:3000"(what I used for access with putty, so I don't think this IP is wrong) and Chrome browser was just saying that "This webpage is not available". Also my security group for new EC2 is exactly the same with the one I used for my other exercises before, so it is also not the reason for this error. I did those work many times with other AMIs that Amazon supports for free but I failed when I patched those high version rails(4.2.0).

Very bizarre because the terminal is saying the WEBrick is running but actually i can't access. Can you give me any help or advice for me to find out what's the problem? I'm so inexperienced and any help or comments will be a huge lesson to me and make me continue to learn. Thank you.


Solution

  • Rails 4.2 no longer listens on all interfaces by default: when running in the same machine you need to connect to

    http://127.0.0.1:3000
    

    (Localhost should work too).

    However since it sounds like you are connecting to a remote server so you need to use the -b option to bind to extra ip addresses, eg

    rails s -b 192.168.1.1