Nilay Singh
Nilay Singh

Reputation: 2341

How to Deploy Rails App to AWS

I am trying to host a Rails app in AWS cloud where I have an EC2 instance and apache and mysql . Here I have uploaded my app but I am unable to bind it with IP. For a testing I am using this blog post https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-unicorn-and-nginx-on-ubuntu-14-04 as a reference . When I am trying to run this command :

RAILS_ENV=production rails server --binding=server_public_IP

I am getting this error :

 /home/ubuntu/.rbenv/versions/2.2.3/lib/ruby/2.2.0/socket.rb:206:in `bind': Cannot assign requested address - bind(2) for 52.24.103.139:3000 (Errno::EADDRNOTAVAIL)

Is there anyone help me understand what is this problem and how to deploy it on AWS apache .

Upvotes: 0

Views: 437

Answers (2)

Ashutosh Agrawal
Ashutosh Agrawal

Reputation: 627

In AWS the machine is not directly assigned the IP, i.e. it is routed using NAT. hence you can not use the public IP to start your rails server directly.

To start server just boot it without the binding parameter rails s production

Or you can use 0.0.0.0 to bind your server, this will start your rails on all the interfaces.

Tip: For production you should ideally server using some web server like nginx/apache using passenger/unicorn

Upvotes: 1

Bhargav Amin
Bhargav Amin

Reputation: 1177

Looking from error it says it cannot bind with ipadd 52.24.103.139:3000

What I would suggest it to open a 'custom TCP port 3000' and try running the same thing again.

May be your app is working on port 3000 not 80. Hope that helps.

Upvotes: 0

Related Questions