- Newest
- Most votes
- Most comments
Based on your description, there are several potential issues preventing connections to ports other than SSH (port 22) on your EC2 instance. Let me analyze the problem:
- iptables Configuration Issue: Looking at your iptables output, I can see a critical issue. The REJECT rule appears before your OpenVPN rule in the INPUT chain:
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
ACCEPT udp -- anywhere anywhere udp dpt:openvpn
This means all traffic is being rejected before the OpenVPN rule can be evaluated. Rules in iptables are processed in order, so your OpenVPN rule is never reached.
-
Protocol Mismatch: Your OpenVPN is configured for UDP port 1194, but your netcat test is using TCP by default. When you run
nc -v -l 0.0.0.0 1194, you're listening on TCP port 1194, not UDP. For UDP testing, you need to use the-uflag with netcat. -
Network ACLs vs. Security Groups: While you mentioned your Network ACLs allow all traffic, remember that Network ACLs are stateless, unlike security groups which are stateful. For Network ACLs, you need to ensure both inbound and outbound rules are properly configured, especially for the ephemeral port range (typically 1024-65535) which is needed for return traffic.
To fix these issues:
- Reorder your iptables rules to place the ACCEPT rule for OpenVPN before the REJECT rule:
sudo iptables -D INPUT -j REJECT --reject-with icmp-host-prohibited
sudo iptables -A INPUT -p udp --dport 1194 -j ACCEPT
sudo iptables -A INPUT -j REJECT --reject-with icmp-host-prohibited
- For testing UDP ports with netcat, use:
# On server
nc -u -v -l 0.0.0.0 1194
# On client
nc -u -v <hostname> 1194
- Double-check your security group to ensure it explicitly allows UDP traffic on port 1194, not just TCP.
If you're still experiencing issues after these changes, you might want to temporarily disable the host firewall completely for testing purposes (remember to re-enable it afterward):
sudo systemctl stop firewalld # For RHEL/CentOS/Fedora
# or
sudo ufw disable # For Ubuntu/Debian
Sources
The connection has timed out. No access to ec2 | AWS re:Post
Unable to access to EC2 via SSH or Instance Connect - Sorted! | AWS re:Post
SSH not working on fresh account, | AWS re:Post
Relevant content
- AWS OFFICIALUpdated 3 years ago

Reordering the iptables rules fixed this!