# Security group vs network ACL

AWS comparisons · Updated 17 November 2026

**Short answer:** Use security groups as your main network control: they are stateful, attach to each resource, allow only what you list and can reference other security groups. Add network ACLs only as a coarse, stateless subnet guard rail, for example to deny a known bad CIDR range or as defence in depth; remember NACLs must allow return traffic on ephemeral ports explicitly.

## Security groups vs NACLs

| Factor | Security group | Network ACL |
|---|---|---|
| Applies to | Network interfaces (instances, tasks, load balancers, endpoints) | Whole subnets |
| State | Stateful: replies are allowed automatically | Stateless: replies need their own rule |
| Rule types | Allow only | Allow and deny |
| Evaluation | All rules considered together | In rule-number order, first match wins |
| Can reference | CIDRs, prefix lists, other security groups | CIDRs only |
| Default behaviour | New group: no inbound, all outbound allowed | Default NACL allows all; a new custom NACL denies all until you add rules |
| Default quota | 60 inbound and 60 outbound rules per group; 5 groups per interface | 20 inbound and 20 outbound rules per NACL |
| Charge | None | None |

## When to rely on security groups

- Almost always. Model tiers with groups: the database group allows port 5432 only from the app group, the app group only from the load balancer group. No IP ranges to maintain as instances come and go.
- Per-resource rules for ECS tasks, Lambda functions in a VPC, interface endpoints and NLBs.
- When you want changes to follow the workload rather than the subnet layout.

AWS's own VPC security guidance names security groups as the primary mechanism and network ACLs as the secondary, coarse-grained layer.

## When to add network ACLs

- Blocking specific CIDR ranges (security groups cannot deny).
- A subnet-wide floor that protects you if someone launches an instance with an over-permissive security group.
- Compliance requirements that ask for subnet-level controls between tiers.

If you write custom NACLs, allow the ephemeral port range for return traffic in both directions (the range depends on the client OS; many teams allow 1024-65535) and leave gaps between rule numbers (10, 20, 30) so you can insert rules later.

## Debugging which layer blocked traffic

1. Check VPC Flow Logs. If the inbound request shows `ACCEPT` but the response shows `REJECT`, a network ACL is dropping the return traffic, because a security group would have allowed the reply automatically.
2. Confirm the security group on the destination allows the source (by group or CIDR) on the right port and protocol.
3. Check the NACLs on both the source and destination subnets, in both directions, including ephemeral ports for the reply.
4. Use Reachability Analyzer in the VPC console to trace the path and name the blocking component.

## Common wrong reasons

- **"NACLs are more secure because they are at the edge."** They are coarser and easier to get wrong. Most outages from NACLs are forgotten return-traffic rules.
- **"Use NACLs to control traffic between instances in one subnet."** NACLs are evaluated when traffic enters or leaves a subnet, not within it.
- **"Open 0.0.0.0/0 in the security group and lock it down with a NACL."** That inverts the model and loses group references.

## Questions

### Are security groups stateful?

Yes. If an inbound rule allows a request, the response is allowed out automatically, regardless of outbound rules. Network ACLs are stateless.

### Can a security group deny traffic?

No. Security groups only have allow rules. Use a network ACL to deny specific ranges.

### Which is evaluated first, NACL or security group?

Inbound traffic passes the subnet's network ACL before reaching the resource's security group; both must allow it.

## When this happens away from your desk

A rule change that blocks production traffic shows up as timeouts, not errors, so the fastest clue is what changed in the network a few minutes earlier. CloudConsole is being built to show alarms next to recent changes on a phone with production guardrails.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Infrastructure security in Amazon VPC](https://docs.aws.amazon.com/vpc/latest/userguide/infrastructure-security.html)
- [Control subnet traffic with network ACLs](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html)
- [Amazon VPC quotas](https://docs.aws.amazon.com/vpc/latest/userguide/amazon-vpc-limits.html)

## Related

- [ALB vs NLB vs Gateway Load Balancer](https://cloudconsole.dev/vs/alb-vs-nlb)
- [NAT Gateway vs NAT instance](https://cloudconsole.dev/vs/nat-gateway-vs-nat-instance)
- [Transit Gateway vs VPC peering](https://cloudconsole.dev/vs/transit-gateway-vs-vpc-peering)
- [VPC Flow Logs rejected traffic in Logs Insights](https://cloudconsole.dev/logs-insights/vpc-flow-logs-rejected-traffic)
- [aws ec2 authorize-security-group-ingress](https://cloudconsole.dev/cli/ec2-authorize-security-group-ingress)
- [ssh: connect to host ec2 port 22: Connection timed out](https://cloudconsole.dev/errors/ec2-ssh-connection-timed-out)

---

Source: https://cloudconsole.dev/vs/security-group-vs-nacl

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
