问题
I put together a rails 5 app and am trying to run it from an AWS ec2 instance. I have set up my security groups, but can't access the special port I selected. What could be wrong?
Security Group Setup:
Ports Protocol Source rails-dev-and-ssh
80 tcp 72.21.xxx.0/24 ✔
22 tcp 72.21.xxx.0/24 ✔
3800 tcp 0.0.0.0/0 ✔
Puma server is started:
[ec2-user@ip-172-31-42-206 Viewer]$ rails server -p 3800 -b 172.31.42.206
=> Booting Puma
=> Rails 5.0.0.1 application starting in development on http://172.31.42.206:3800
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.6.0 (ruby 2.3.0-p0), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://172.31.42.206:3800
Use Ctrl-C to stop
From the same instance, both of these requests return success (rails version and blob of stuff):
curl http://172.31.42.206:3800 <private IP>
curl http://54.86.xxx.xx:3800 <public IP
But from my computer that's not in EC2, I can curl port 80 no problem but not port 3800, where Puma is running. This leads me to believe that my AWS VPC config is OK but something is wrong with the IP that Puma is binding to. I also tried binding to 0.0.0.0.
$ curl http://54.86.xxx.xx/ <the public ip, port 80, succeeds>
hi raj var www html
$ curl http://54.86.xxx.xx:3800
curl: (7) Failed to connect to 54.86.xxx.xx port 3800: Operation timed out
回答1:
It's not AWS or rails.... It's my stupid office firewall that's keeping me from accessing an arbitrary port in ec2. I can access the site fine from my phone. Sorry!
来源:https://stackoverflow.com/questions/40118198/trouble-connecting-to-rails-server-in-aws