myungstack
myungstack

Reputation: 23

Setting up Rails on Amazon AMI EC2

I have recently created an Amazon AMI(linux) instance on an EC2. after doing all the yum stuff, when I do rails server, the cmd shows no errors at all, but when i try to access http:public_ip:3000 through Firefox I get "Unable to connect"

I have already installed Ruby, NodeJs, Rails, and rvm. I have asked on IRC and have tried rails s -b http://public_ip:3000 with

/home/ec2-user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/socket.rb:205:in >`bind': Cannot assign requested address - bind(2) for 52.48.217.79:3000 >(Errno::EADDRNOTAVAIL)

in return.

I've also tried ssh to the elastic IP, and when I do rails s -b http://public_ip:3000 I get:

[2016-01-17 01:43:23] INFO ruby 2.3.0 (2015-12-25) [x86_64-linux] Exiting /home/ec2-user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/socket.rb:231:in >`getaddrinfo': getaddrinfo: Name or service not known (SocketError)

this is all just to make sure that rails was installed well and running(I want to see the default rails page). Can anyone help?

Upvotes: 2

Views: 558

Answers (1)

MWhit
MWhit

Reputation: 158

You want to bind to 0.0.0.0.

Rails used to do this for you by default, but starting with 4.2 it only binds to localhost by default, so the command will be rails s -b 0.0.0.0.

You'll also need to make sure you have a rule set up allowing TCP traffic to port 3000 in your EC2 security group

Upvotes: 3

Related Questions