Troubleshoot rejected AWS traffic with VPC Flow Logs

Troubleshoot rejected AWS traffic with VPC Flow Logs

When an AWS workload times out, the first useful question is whether the traffic reached the network interface you expected. VPC Flow Logs can narrow that search. Send the records to CloudWatch Logs, filter for the affected interface and time window, then compare source, destination, and port before changing a security group or network ACL.

This walkthrough uses one elastic network interface in a test VPC and CloudWatch Logs Insights. It reads connection metadata without collecting application payloads.

Scope the capture to the problem

Start with the destination port, time of the failure, and the ENI associated with the affected workload. Use an existing flow log if it already covers that interface and captures the needed traffic. For a short investigation, logging one ENI is usually easier to read than opening a VPC-wide search.

You need access to a test resource and an IAM role that VPC Flow Logs can assume to write to CloudWatch Logs. The principal creating the subscription needs iam:PassRole on that delivery role in addition to permission to create the flow log. The analyst needs permission to read and query the CloudWatch log group.

  1. In the EC2 console, choose Network Interfaces, select the test ENI, and choose Actions → Create flow log.
  2. Choose All for the traffic filter so you can compare accepted and rejected flows. For a short lab, choose a one-minute maximum aggregation interval.
  3. Choose Send to CloudWatch Logs, a dedicated test log group, the delivery role, and the AWS default record format. Use a short log retention period for the lab unless your organization requires longer retention.

Flow logs begin collecting after creation and delivery is asynchronous. Allow time for publication before interpreting an empty query. See the AWS setup steps and record format and delivery behavior.

Find rejected flows on one interface

Open CloudWatch → Logs Insights, select the destination log group, and restrict the time picker to the incident window. Substitute your interface ID and destination port in the following query. It uses the fields CloudWatch discovers for the default VPC Flow Logs format in a Standard-class log group.

fields @timestamp, interfaceId, srcAddr, srcPort, dstAddr, dstPort, protocol, packets
| filter interfaceId = "eni-0123456789abcdef0" and logStatus = "OK"
| filter action = "REJECT" and dstPort = 443
| sort @timestamp desc
| limit 50

A matching row gives you the flow tuple and packet count. It does not identify the exact security rule. The default REJECT action can represent a security group or network ACL denial, and some packets are rejected after a connection closes. Correlate the timestamps with the application failure and check that the source and destination match the connection you were investigating.

To see which sources account for most of the rejected records, run a grouped query on the same time window. A record is an aggregate for a capture window, so use sum(packets) to compare reported packet volume. Neither count measures unique user requests.

fields interfaceId, action, logStatus, srcAddr, dstAddr, dstPort, packets
| filter interfaceId = "eni-0123456789abcdef0" and logStatus = "OK"
| filter action = "REJECT" and dstPort = 443
| stats count(*) as flowRecords, sum(packets) as rejectedPackets by srcAddr, dstAddr, dstPort
| sort rejectedPackets desc
| limit 20

Follow the evidence to the next check

  • The intended connection is rejected. Confirm the source and destination security group rules and the subnet ACLs. Security groups are stateful and network ACLs are stateless, so an ACL may need a rule for the response traffic as well. Review both sides of the path before making the narrowest correction.
  • The connection is accepted but the request still times out. Check for return traffic, then inspect the application listener, TLS settings, target group health, and application logs. ACCEPT at one ENI does not prove an end-to-end request succeeded.
  • No matching rows appear. Check the Region, selected log group, ENI, port, and time window. Review the flow log’s destination status and delivery role. Look for SKIPDATA before concluding traffic was absent. If the log uses a custom format, inspect the raw message and use a parse pattern that matches its actual field order.

If the path supports it, use VPC Reachability Analyzer to inspect network configuration. It analyzes the configured path and does not send packets. For a test verification, repeat the same legitimate connection from the same client after an approved change, query both ACCEPT and REJECT, and confirm the application responds.

Keep the logging cost proportional

Use a focused query range and select only the required log groups. Flow Logs delivery, storage, and Logs Insights queries can incur charges. Review CloudWatch pricing for your Region. When the lab is over, remove the dedicated flow log subscription and retain or delete its log group according to your policy. Deleting the subscription stops new delivery and leaves existing records in the destination.

For query variations, see CloudWatch’s discovered VPC Flow Logs fields and Logs Insights query syntax.

Related reading

Techmandra Avatar

Leave a Reply

Your email address will not be published. Required fields are marked *