Search code examples
ruby-on-railsamazon-web-serviceselastic-ip

Rails server on AWS hosting


I have hosted a rails application on AWS. Every time I want to access my website, I have to go through some steps which are quite repetitive.

1. ssh -i <<a>my-keypair-pem> ec2-user@<<a>AWS-IPv4-public-IP>
2. rails s -p <<a>port> -b 0.0.0.0

After some time, I also get this error

'packet_write_wait: Connection to <AWS-IPv4-public-IP> port 22: Broken pipe'

I did some research and can't seem to find a way to keep my application running 24/7 without having to do these steps before accessing every time. My AWS instance is on 24/7, so the website should run 24/7 as well.

Would assign an elastic IP to my instance help?

Appreciate any guidance.

EDIT: I followed this tutorial initially https://www.youtube.com/watch?v=jFBbcleSPoY and that is where I found the steps mentioned above.


Solution

  • Resolved the issue with https://mosh.org/, for anyone who stumbles on this post in the future.

    Download and install mosh (mobile shell)
    Run the modified version of the command mentioned in my original question

    mosh -ssh="ssh -i <your-keypair.pem>" ec2-user@<AWS-Instance-IP>

    This resolved my packet_write_wait issues and I don't have to keep restarting the rails server.