How to open a port to an EC2 instance

To open a port to an EC2 instance, do:

  • ec2-authorize -p <port number> <security group> (from any machine with the ec2 command-line tools)
  • If the server has iptables: sudo /sbin/iptables -A INPUT -p tcp --dport <port number> -j ACCEPT (on the server)

Speaking of iptables, here’s: