Network Reachability: Reachability Analyzer and VPC Flow Logs

“The app can’t reach the database” starts more fights between network and app teams than any other ticket. VPC Flow Logs settle it with evidence, because they record every flow on every network interface along with whether it was accepted or rejected. Reachability Analyzer gives you the other half, telling you whether your configuration should allow the path at all and, if it doesn’t, which rule blocks it.

You’ll build a small app-to-database path, switch on flow logs for saat-vpc, query them with Logs Insights and run Reachability Analyzer. After that you’ll break the path in two different ways and see how the two tools together point to the team that owns the fix.

TimeYou needBy the end you can
75 minutesLessons 8 to 13 and 24 done (saat-vpc, endpoint scripts, Logs Insights), Lesson 57 done, signed in as saat-admin. Cost: about USD 0.50 (Reachability Analyzer charges per analysis, flow logs per GB, plus two small instances and the SSM endpoints for an hour).Turn on VPC Flow Logs to CloudWatch Logs, query them with Logs Insights, run Reachability Analyzer and read what it tells you, and tell network problems apart from application problems.

What it is, in one line

VPC Flow Logs record the IP traffic to and from network interfaces in a VPC, marking each flow ACCEPT or REJECT, and Reachability Analyzer checks whether your configuration allows a path.

In Simple Words

The gate register and the map

A housing society keeps a register at the gate with every visitor, the flat they’re going to, the time they came in and whether the guard let them through, and that register is your flow log, a record of what really happened. The society also has a map showing all the gates and their rules, so even before a visitor turns up you can trace a route on it and see which gate would stop them, which is what Reachability Analyzer does. If the map says the route is open and the register says the visitor got in, but your friend still didn’t open the door, then the problem is inside the flat and not at the gate.

Engineer's View

How the two tools work

VPC Flow Logs can be turned on per VPC, subnet or network interface, for ACCEPT, REJECT or ALL traffic, and sent to CloudWatch Logs, S3 or Firehose. Each record holds the source and destination address and port, the protocol, packets, bytes, a time window and the action.

Records are aggregated over 1 or 10 minutes and turn up after a delay, so think of them as evidence and not a live view. CloudWatch Logs Insights picks up the default fields (srcAddr, dstPort, action) by itself.

Flow logs don’t capture packet contents, DNS queries to the Amazon resolver or traffic to the instance metadata service. A REJECT comes from a security group or network ACL, while an ACCEPT only means the network let it through and says nothing about whether an application answered.

Reachability Analyzer doesn’t send any packets. It models the routes, security groups, NACLs, gateways and peering between a source and a destination and returns NetworkPathFound, along with an explanation code and the component that blocks the path.

You pay for each analysis. Network Access Analyzer is a related tool for finding unwanted access across a whole VPC.

How it works, step by step

On a “can’t reach” ticket, use them together like this.

1Ask the map

Run Reachability Analyzer between the two resources on the right port, and if it names a blocking rule you’re done in minutes.

Reachability Analyzer reads configuration while VPC Flow Logs record traffic

2Read the register

Query the flow logs for that port and those addresses. A REJECT confirms a security group or NACL, and no records at all points to routing, DNS or the wrong IP.

3Look above the network

When the analyzer says reachable and the flows are ACCEPT, the network is fine, so check the service, its port and the host firewall.

4Read the results correctly

Each pattern points at a different owner:

How to read VPC Flow Logs results: REJECT, ACCEPT with failures, no records

Take both outputs to the incident call, and the “it’s the network” versus “it’s the app” argument ends quickly.

✅ Checkpoint: You can say what flow logs do and don’t record, what Reachability Analyzer checks, and what ACCEPT with a failing app tells you.

Hands-on lab: prove where app58 to db58 breaks

Before you run any command, double-check it

Read every command twice before you press Enter. Check the target: the system or account, the IDs, the names and the sizes. These commands are for learning and were tested in our lab, not on your system. At work, run the read-only list commands first, follow your change process, make sure a backup exists, and ask a second person to check anything that changes or deletes data. You run them at your own risk.

Sign in, start the endpoints and set names:

cd C:\aws-lab
aws login --profile saat-admin
$env:AWS_PROFILE = 'saat-admin'
$v = Get-Content C:\aws-lab\saat-vpc.json | ConvertFrom-Json
.\Start-SsmEndpoints.ps1

1Build an app-to-database path

Paste this whole block. db58 runs a small web service on port 8080, and app58 calls it:

$dbSg = aws ec2 create-security-group --group-name saat-db58-sg --description "db58 port 8080 from app tier" --vpc-id $v.VpcId --query GroupId --output text
aws ec2 authorize-security-group-ingress --group-id $dbSg --ip-permissions "IpProtocol=tcp,FromPort=8080,ToPort=8080,UserIdGroupPairs=[{GroupId=$($v.AppSg),Description=8080-from-app}]" | Out-Null
$ami = aws ssm get-parameter --name /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64 --query Parameter.Value --output text
$app = aws ec2 run-instances --image-id $ami --instance-type t3.micro --subnet-id $v.PrivateA --security-group-ids $v.AppSg --iam-instance-profile Name=saat-ec2-ssm-profile --metadata-options HttpTokens=required --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=app58},{Key=course,Value=saatvedha-aws},{Key=lesson,Value=58}]' --query "Instances[0].InstanceId" --output text
$db = aws ec2 run-instances --image-id $ami --instance-type t3.micro --subnet-id $v.PrivateB --security-group-ids $dbSg --iam-instance-profile Name=saat-ec2-ssm-profile --metadata-options HttpTokens=required --user-data "#!/bin/bash
systemd-run --unit=web8080 python3 -m http.server 8080 --directory /tmp" --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=db58},{Key=course,Value=saatvedha-aws},{Key=lesson,Value=58}]' --query "Instances[0].InstanceId" --output text
foreach ($x in $app, $db) { do { Start-Sleep 20; $p = aws ssm describe-instance-information --filters "Key=InstanceIds,Values=$x" --query "InstanceInformationList[0].PingStatus" --output text } until ($p -eq 'Online') }
$dbIp = aws ec2 describe-instances --instance-ids $db --query "Reservations[0].Instances[0].PrivateIpAddress" --output text
function Invoke-Linux([string]$Id, [string[]]$Lines) {
  @{ commands = $Lines } | ConvertTo-Json | Set-Content lx-cmd.json
  $cmd = aws ssm send-command --document-name AWS-RunShellScript --instance-ids $Id --parameters file://lx-cmd.json --query Command.CommandId --output text
  do { Start-Sleep 5; $st = aws ssm get-command-invocation --command-id $cmd --instance-id $Id --query Status --output text 2>$null } until ($st -in 'Success', 'Failed', 'TimedOut')
  aws ssm get-command-invocation --command-id $cmd --instance-id $Id --query StandardOutputContent --output text
}
function Test-App { Invoke-Linux $app @(('curl -s -o /dev/null -w "%{http_code}\n" --max-time 5 http://' + $dbIp + ':8080/; echo "curl exit $?"')) }
Test-App

You should see something like this:

200
curl exit 0

app58 in saat-private-a reaches db58 in saat-private-b on port 8080, and that’s your “it worked yesterday” baseline.

2Turn on VPC Flow Logs and query them

Paste this whole block. Flow records can take up to about 10 minutes to arrive, so it generates some traffic and then waits:

aws logs create-log-group --log-group-name /saat/vpc-flow
aws logs put-retention-policy --log-group-name /saat/vpc-flow --retention-in-days 1
'{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "vpc-flow-logs.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }' | Set-Content fl-trust.json
'{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": ["logs:CreateLogStream", "logs:PutLogEvents", "logs:DescribeLogGroups", "logs:DescribeLogStreams"], "Resource": "*" } ] }' | Set-Content fl-policy.json
$flRole = aws iam create-role --role-name saat-flowlogs-role --assume-role-policy-document file://fl-trust.json --query Role.Arn --output text
aws iam put-role-policy --role-name saat-flowlogs-role --policy-name write-logs --policy-document file://fl-policy.json
Start-Sleep 15
$fl = aws ec2 create-flow-logs --resource-type VPC --resource-ids $v.VpcId --traffic-type ALL --log-destination-type cloud-watch-logs --log-group-name /saat/vpc-flow --deliver-logs-permission-arn $flRole --max-aggregation-interval 60 --query "FlowLogIds[0]" --output text
1..5 | ForEach-Object { Test-App | Out-Null }
Start-Sleep 600
function Get-Flows([int]$Port, [int]$Minutes = 15) {
  $e = [DateTimeOffset]::UtcNow.ToUnixTimeSeconds(); $s = $e - $Minutes * 60
  $q = "fields srcAddr, dstAddr, dstPort, action | filter dstPort = $Port | stats count(*) as flows by srcAddr, dstAddr, action"
  $qid = aws logs start-query --log-group-name /saat/vpc-flow --start-time $s --end-time $e --query-string $q --query queryId --output text
  do { Start-Sleep 3; $r = aws logs get-query-results --query-id $qid | ConvertFrom-Json } until ($r.status -in 'Complete', 'Failed', 'Cancelled')
  $r.results | ForEach-Object { $h = @{}; $_ | ForEach-Object { $h[$_.field] = $_.value }; '{0,-14} -> {1,-14} {2,-7} {3}' -f $h.srcAddr, $h.dstAddr, $h.action, $h.flows }
}
Get-Flows 8080

You should see something like this:

10.20.11.37    -> 10.20.12.84    ACCEPT  6

Each line is one source, destination and action with its count of flow records, and app58’s calls to db58 on 8080 were all accepted.

CloudWatch log stream of VPC flow logs showing ACCEPT records from app58 to db58 on port 8080
The flow log stream for the network interface shows app58’s connections to db58 on port 8080, each marked ACCEPT.
VPC Flow Logs lab output: path found and accepted flows on port 8080
Accepted flows on port 8080, roughly like this.

3Ask Reachability Analyzer

Paste this whole block:

$path = aws ec2 create-network-insights-path --source $app --destination $db --protocol tcp --destination-port 8080 --tag-specifications 'ResourceType=network-insights-path,Tags=[{Key=Name,Value=app58-to-db58},{Key=course,Value=saatvedha-aws}]' --query NetworkInsightsPath.NetworkInsightsPathId --output text
function Test-Reach {
  $a = aws ec2 start-network-insights-analysis --network-insights-path-id $path --query NetworkInsightsAnalysis.NetworkInsightsAnalysisId --output text
  do { Start-Sleep 10; $st = aws ec2 describe-network-insights-analyses --network-insights-analysis-ids $a --query "NetworkInsightsAnalyses[0].Status" --output text } until ($st -ne 'running')
  aws ec2 describe-network-insights-analyses --network-insights-analysis-ids $a --query "NetworkInsightsAnalyses[0].[NetworkPathFound,Explanations[0].ExplanationCode,Explanations[0].SecurityGroup.Id]" --output text
}
Test-Reach

You should see something like this:

True    None    None

The configuration allows the path and the flow logs show it in use. In the console, open VPC > Reachability Analyzer and then the analysis to see the path hop by hop: ENI, security groups, route table, NACLs and target ENI.

VPC Reachability Analyzer path from app58 to db58 on TCP 8080 marked Reachable with every hop
Reachability Analyzer’s path from app58 to db58 shows every hop allowing TCP 8080, so the network isn’t the problem.

✅ Checkpoint: curl returns 200, Get-Flows shows ACCEPT flows to 10.x.x.x on 8080, and Test-Reach returns True.

Break It, Then Fix It

Here are two failures with the same complaint, “the app can’t reach the database”, and different owners.

1Break it: a security group rule removed

Remove db58’s rule, call it again and then ask both tools:

aws ec2 revoke-security-group-ingress --group-id $dbSg --ip-permissions "IpProtocol=tcp,FromPort=8080,ToPort=8080,UserIdGroupPairs=[{GroupId=$($v.AppSg)}]" | Out-Null
1..3 | ForEach-Object { Test-App }
Test-Reach
Start-Sleep 600
Get-Flows 8080 -Minutes 12

You’ll get something like this:

000
curl exit 28
False   ENI_SG_RULES_MISMATCH   sg-0db58a1b2c3d4e5f6
10.20.11.37    -> 10.20.12.84    REJECT  3

curl timed out (exit 28), the analyzer names db58’s security group and the flow logs record REJECT at db58. That’s a fix on the network side, and you can prove it to the team in one message. Fix: put the rule back:

aws ec2 authorize-security-group-ingress --group-id $dbSg --ip-permissions "IpProtocol=tcp,FromPort=8080,ToPort=8080,UserIdGroupPairs=[{GroupId=$($v.AppSg),Description=8080-from-app}]" | Out-Null
Test-App

You should see this:

200
curl exit 0

2Break it: the service stops

Stop the web service on db58 and ask the same questions again:

Invoke-Linux $db @('systemctl stop web8080; echo stopped') | Out-Null
1..3 | ForEach-Object { Test-App }
Test-Reach
Start-Sleep 600
Get-Flows 8080 -Minutes 12

You’ll get something like this:

000
curl exit 7
True    None    None
10.20.11.37    -> 10.20.12.84    ACCEPT  9
Reachability problems: security group reject and service stopped behind an accepted flow
Here are both failures and their fixes, something like this.

Exit 7 means “connection refused”: the packets arrived and the OS replied that nothing is listening on 8080. The analyzer says the path is allowed and the flow logs show ACCEPT, so changing a firewall won’t help.

This one belongs to the app team. Fix: start the service:

Invoke-Linux $db @('systemd-run --unit=web8080 python3 -m http.server 8080 --directory /tmp; sleep 2; ss -ltn | grep 8080')
Test-App

You should see something like this:

LISTEN 0      5            0.0.0.0:8080      0.0.0.0:*
200
curl exit 0

Now clean up:

aws ec2 delete-flow-logs --flow-log-ids $fl | Out-Null
aws logs delete-log-group --log-group-name /saat/vpc-flow
aws iam delete-role-policy --role-name saat-flowlogs-role --policy-name write-logs
aws iam delete-role --role-name saat-flowlogs-role
$an = aws ec2 describe-network-insights-analyses --network-insights-path-id $path --query "NetworkInsightsAnalyses[].NetworkInsightsAnalysisId" --output text
foreach ($x in ($an -split '\s+')) { if ($x) { aws ec2 delete-network-insights-analysis --network-insights-analysis-id $x | Out-Null } }
aws ec2 delete-network-insights-path --network-insights-path-id $path | Out-Null
aws ec2 terminate-instances --instance-ids $app $db | Out-Null
aws ec2 wait instance-terminated --instance-ids $app $db
aws ec2 delete-security-group --group-id $dbSg
.\Stop-SsmEndpoints.ps1
Remove-Item fl-trust.json, fl-policy.json, lx-cmd.json

✅ Checkpoint: You found a security group block from a REJECT plus the analyzer’s explanation, and a stopped service from an ACCEPT plus a refused connection. The flow log, log group, role, analyses, path, instances and security group have been removed.

This happened at work

Three days of “it’s the firewall”

At a bank, the loan app suddenly couldn’t reach a new pricing service. The app team raised a firewall ticket, the network team went through the rules and said everything was open, and the ticket bounced between the two teams for three days. In the end a cloud engineer switched on flow logs for the pricing service’s subnet and found every request marked ACCEPT, and Reachability Analyzer agreed the path was open. So the network wasn’t the issue at all: the pricing service had been deployed listening on 127.0.0.1 instead of 0.0.0.0, and it refused every connection from outside the host. One line of config fixed it. Now the bank keeps flow logs on in production with short retention, and its incident template asks for a Reachability Analyzer result and a flow log query before anyone raises a firewall ticket.

Common mistakes and troubleshooting

MistakeWhat happensWhat to do
Reading ACCEPT as “the app works”Chasing the network for an app bugACCEPT only means the network allowed it
Checking flow logs immediatelyEmpty results, wrong conclusionAllow up to about 10 minutes for delivery
Flow logs with long retention on busy VPCsLarge log billsShort retention, S3 for long-term, filter REJECT
Expecting DNS or metadata traffic in flow logsMissing recordsUse Route 53 Resolver query logs for DNS
Running analyzer for every testCharges add upRun it when a path is in question
Raising firewall tickets without evidenceDays of back and forthAttach analyzer output and a flow log query

Interview questions

Click a question to open it. Each one is phrased the way an interviewer would ask it, and underneath you’ll find why they ask it and one way you could answer in your own words.

Fresher level

1. Can you explain in simple words what VPC Flow Logs record?

Why they ask this: They’re checking you know what flow logs can and can’t show, so you don’t expect them to answer everything.

How you might answer: They record details of IP traffic on network interfaces: the addresses, ports, protocol, packets, bytes, the time window and whether it was ACCEPT or REJECT. They don’t show what’s inside the packets. I usually compare it to a phone bill, where you see who called whom and for how long but not what was said.

2. What does Reachability Analyzer do, and when would you use it?

Why they ask this: They want to see you know a tool that checks the network design without sending real traffic.

How you might answer: It looks at the configuration between a source and a destination (routes, security groups, NACLs and gateways) and tells you whether a path exists or which piece blocks it. I reach for it when something can’t connect and I want to know which rule to look at instead of guessing.

3. You’re turning on flow logs for a VPC. Where can you send them?

Why they ask this: They’re checking basic setup knowledge and whether you think about where the logs will be most useful.

How you might answer: CloudWatch Logs, Amazon S3 or Kinesis Data Firehose. I’d use CloudWatch Logs when I want quick searching, and S3 when I need to keep a lot of logs cheaply.

2–5 years experience

4. Flow logs show ACCEPT for the traffic, but the app still gets “connection refused”. What would you check next?

Why they ask this: They want to see you can read the evidence and stop blaming the network once it’s clearly fine.

How you might answer: ACCEPT means the network let it through, so I’d move up to the server and check the service is running and listening on the right interface and port. Then I’d look at the host firewall, because the AWS network rules don’t cover that.

5. You see REJECT records on the target network interface. How would you find the rule that’s blocking it?

Why they ask this: They want to see you go from a symptom to the exact rule, and then find out how that rule got there.

How you might answer: I’d run Reachability Analyzer for that source and destination, since it names the security group or NACL entry blocking the path, and then check CloudTrail for recent changes to that rule to see who changed it and when.

6. A colleague is searching flow logs for DNS traffic and finds nothing. What would you tell them?

Why they ask this: They want to know you understand the blind spots of flow logs, so you don’t waste time looking for records that will never exist.

How you might answer: I’d tell them flow logs don’t capture DNS queries to the Amazon resolver, and they also skip instance metadata, Windows license activation, DHCP and some other AWS-internal traffic. For DNS they should look at Route 53 Resolver query logs.

Senior level

7. How would you design network visibility for a regulated company with many AWS accounts?

Why they ask this: They want to see how you’d combine central logging, querying and compliance checks while keeping the cost in check.

How you might answer: Flow logs from every VPC would go to a central S3 bucket in a log account, in Parquet and partitioned, and we’d query them with Athena, with a short CloudWatch retention for quick hot searches. For compliance I’d add Route 53 Resolver query logs and Network Access Analyzer scopes, and set alerts on unusual REJECT patterns.

8. The flow log bill has become a problem. How would you bring the cost down?

Why they ask this: They want to see you can keep the visibility you need without paying for logs that nobody reads.

How you might answer: I’d log only the ENIs or subnets that need it, use REJECT-only where that’s enough, and send logs to S3 with a lifecycle rule instead of CloudWatch. A custom format with just the fields we need and the 10-minute aggregation interval would cut it further.

Quick quiz

Q1. What does a REJECT in flow logs mean?

  1. App crashed
  2. A security group or NACL dropped it
  3. DNS failed
  4. Disk full
Show answer

B — Network controls decided to drop it.

Q2. curl exit 7 with ACCEPT flows means?

  1. SG blocked it
  2. Nothing listens on the port
  3. Route missing
  4. Wrong Region
Show answer

B — Connection refused by the host.

Q3. Does Reachability Analyzer send real packets?

  1. Yes
  2. No, it analyses configuration
  3. Only ICMP
  4. Only on weekends
Show answer

B — It models the path.

Q4. Why might flow logs show nothing right after a test?

  1. They’re off
  2. Delivery delay
  3. Wrong port
  4. IAM
Show answer

B — Records arrive after aggregation and delivery.

Q5. Which traffic do flow logs not capture?

  1. TCP 443
  2. DNS to the Amazon resolver
  3. SSH
  4. HTTP
Show answer

B — Use Resolver query logs for DNS.

Quick recap

  • Reachability Analyzer tells you whether the configuration allows a path and what blocks it.
  • VPC Flow Logs show what traffic actually crossed, with ACCEPT or REJECT.
  • REJECT = security group or NACL; ACCEPT + failure = look at the app.
  • Give flow records about 10 minutes to arrive, and query them with Logs Insights.
  • Keep retention short, and bring evidence to every firewall ticket.

Next lesson

Lesson 59: IAM AccessDenied decoded → Next you’ll decode encoded authorization messages and work out which policy, boundary or SCP is denying a request.

Further reading: VPC Flow Logs

If you want to go further with VPC Flow Logs, read Logging IP traffic using VPC Flow Logs and What is Reachability Analyzer?. The full plan for this course is on the AWS Cloud Administration course page.

Scroll to Top

This website uses cookies

We use a few cookies to keep this site working. If you allow it, we also use Google Analytics to count visits so we can improve our lessons. You can accept all, deny the optional ones, or choose what to allow.