In addition to @Will's answer, its possible that whichever Ubuntu AMI you're using came with restrictive iptables rules by default.
Use:
sudo iptables -L
to list any current rules that exist.
Use:
sudo iptables -A INPUT -p tcp --dport 5000 -j ACCEPT
to open the port if necessary.