Defender for Endpoint - Firewall filtering events
MDE Firewall Events
Query
DeviceEvents
| where ActionType in ("FirewallOutboundConnectionBlocked", "FirewallInboundConnectionBlocked", "FirewallInboundConnectionToAppBlocked")
| project DeviceName, DeviceId , Timestamp , InitiatingProcessFileName , InitiatingProcessParentFileName, RemoteIP, RemotePort, LocalIP, LocalPort
| summarize MachineCount=dcount(DeviceId) by RemoteIPAbout this query
Defender for Endpoint - Firewall filtering events
Query Information
Description
Get all filtering events done by the Windows filtering platform. This includes any blocks done by Windows Firewall rules, but also blocks triggered by some 3rd party firewalls.
For firewall events to be displayed in Defender for Endpoint, you'll need to enable the audit policy, see Audit Filtering Platform connection. Firewall covers the following events
Within the Windows Event log the following events are created:
- 5025 - firewall service stopped
- 5031 - application blocked from accepting incoming connections on the network
- 5157 - blocked connection
References
- Investigate devices in the Microsoft Defender for Endpoint Devices list
- Audit Filtering Platform Connection
Microsoft 365 Defender
Find Inbound and Outbound blocked events
Explanation
The query is designed to retrieve and summarize firewall filtering events from Microsoft Defender for Endpoint. It focuses on identifying instances where network connections were blocked by either Windows Firewall or third-party firewalls. Here's a simple breakdown of what the query does:
-
Data Source: It pulls data from
DeviceEvents, which logs various device-related activities. -
Filter Criteria: The query filters events to only include those where network connections were blocked. Specifically, it looks for three types of blocked events:
- Outbound connections blocked by the firewall.
- Inbound connections blocked by the firewall.
- Inbound connections to an application that were blocked.
-
Selected Information: For each blocked event, the query extracts specific details:
DeviceName: The name of the device where the event occurred.DeviceId: The unique identifier of the device.Timestamp: When the event happened.InitiatingProcessFileName: The name of the process that initiated the connection.InitiatingProcessParentFileName: The name of the parent process of the initiating process.RemoteIPandRemotePort: The IP address and port number of the remote connection.LocalIPandLocalPort: The IP address and port number on the local device.
-
Summarization: The query summarizes the data by counting the number of unique devices (
MachineCount) that experienced blocked connections, grouped by theRemoteIP.
In essence, this query helps identify and analyze blocked network connections across devices, providing insights into potential security incidents or misconfigurations in firewall settings.
Details

Alex Verboon
Released: April 16, 2026
Tables
Keywords
Operators