简体   繁体   中英

Run Rails application in AWS Cloud9

Recently I migrated my workspace from the old Cloud9 to AWS Cloud9. Now I can no longer run my application. I'm hoping somebody on Stack Overflow might have an idea what the problem is because AWS' help forums and documentations skip past the parts I'm missing.

The "Run" button tries run the last file that I was viewing and editing, rather than my application as a whole.

So I try to start it running in the terminal with "rails s -b $IP -p $PORT". I get this line:

Listening on tcp://127.0.0.1:8080

So the program should be running, right? But the green "Run" button is now disabled, and I don't get the spinning icon in my terminal window that I used to get with old Cloud9.

Next I try getting the application's url from the "Share" menu, which is:

18.212.63.5

When I try to navigate to this url in another window, I get an error

ERR_CONNECTION_TIMED_OUT

When I try to "Preview Running Application" with the IDE, I get the error

66af0558a4b44f8bb019cb5628f6b28f.vfs.cloud9.us-east-1.amazonaws.com refused to connect.

In related news, I'm highly frustrated with AWS for a lot of other reasons. Should I consider switching to a different IDE? Or keep trying to learn this one?

Thank you in advance for any insight.

I had what I believe was a similar problem. The preview won't show if the app is being served over http, rather than https:

https://docs.aws.amazon.com/cloud9/latest/user-guide/troubleshooting.html#troubleshooting-app-preview-http

A simple workaround here is just to remove the 's' from the amazonaws.com URL listed in the 'refused to connect' error, and then press the button to preview the application in a browser tab.

Also note that on AWS C9 you shouldn't need

rails s -b $IP -p $PORT

It should usually be enough to do

rails server

(though check that, for example, your puma.rb file is set to run on port 8080 rather than 3000)

See also https://forums.aws.amazon.com/thread.jspa?messageID=899522 , which provides a set of diagnostic commands that you can run from a terminal session in the AWS Cloud9 IDE for your development environment that can output the incoming traffic rules for the environment's associated Amazon EC2 instance's security group and network ACL. These traffic rules need to allow incoming traffic for the correct protocol and port.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM