How to Block an IP Address on Your Site with Cloudflare

Cloudflare can block requests from a selected source IP with a custom rule in its web application firewall (WAF). The rule applies to web traffic that passes through Cloudflare for the protected site. Before creating one, verify that the affected hostname is proxied and that the IP was observed in relevant security or application evidence. An IP address can be shared by many visitors, so even a block of one address may affect people unrelated to the incident.
Limit the rule to the address and part of the site involved in the unwanted traffic. Test both the blocked request and requests that should still work, then review Security Events for unexpected matches. Before enabling the rule, make sure you can still reach the Cloudflare dashboard to disable it if necessary.
Confirm the Request Passes through Cloudflare
Check the exact DNS record for the website hostname. A proxied A, AAAA, or CNAME record routes supported HTTP and HTTPS traffic through Cloudflare. In the usual setup, a DNS-only record sends web traffic to the configured destination instead; also check whether a CNAME chain leads to another proxied record. A WAF custom rule will not see a direct-origin request that bypasses the Cloudflare proxy. Identify any alternative route to the origin, such as a DNS-only hostname, before expecting the rule to cover all visitors.
Inspect recent traffic or Security Events for the suspected address, requested host, URL path, time, and prior action. Confirm that the requests belong to the site you administer and show the behavior you intend to stop. Visitors on mobile networks, office networks, or VPNs may share a public IP address, and a dynamic address can be reassigned. If the evidence concerns only one abusive path, a path-scoped rule can reduce collateral impact compared with blocking the same address everywhere.
Match the Address and Relevant Part of the Site
In the Cloudflare dashboard, select your domain and open Security rules. Choose Create rule, then Custom rules, and enter a name that identifies the reason for the block. Under the matching conditions, select the source IP address field and an equality comparison with the address you want to block.
In the expression editor, an exact address match looks like ip.src eq 192.0.2.44. Here, 192.0.2.44 is a documentation address, not a real visitor selected for blocking. Replace it with the source address Cloudflare evaluates for the unwanted requests, rather than your website's origin address or a Cloudflare server address.
Add a hostname or path condition when the incident is limited to part of the site. For example, (ip.src eq 192.0.2.44 and http.host eq "example.com" and http.request.uri.path eq "/login") matches only when the address, hostname, and path all match. Substitute your own hostname and path along with the address.
The and operators matter: replacing them with or would match a request satisfying any one condition, potentially blocking every visitor to that login path. Keep only the IP condition if the intended scope really is every proxied hostname in the selected domain. Do not expand one observed address into a network range just because the addresses belong to the same internet provider.
Check any URL Rewrite Rules before choosing a path value. Rewrites run before WAF custom rules, so a path condition can see a rewritten path rather than the path originally requested by the visitor.
Set the Action and Deploy the Rule
Select Block under the action settings to refuse matching requests. Managed Challenge is a different choice: it can let a visitor proceed after the challenge is satisfied, so it is not equivalent to an unconditional block. If you share the selected address with other administrators, check how the rule would affect access to the site before enabling it.
Save as Draft keeps an unfinished rule from taking effect; Deploy enables the completed rule. Record why you added the block and when a temporary rule should be reviewed. Check the existing rule order as well: an earlier custom rule that skips all remaining custom rules can prevent this block from running, and an IP Access rule that allows the address can bypass custom rules entirely.
Test Requests That Should and Should Not Be Blocked
From a controlled client using the matched address, request the affected hostname and path. Find the corresponding security event and confirm that the new rule caused the block; another rule could return a similar response. Also test an address that should remain allowed and, for a path-specific block, another path from the selected address.
If you cannot make a test request from the selected address, review matching events from actual traffic. You can separately test an equivalent rule with a client you control, but that does not prove that the original address has reached Cloudflare or matched the deployed rule.
If no matching event appears, check whether the request passed through Cloudflare and whether its evaluated address matches the rule. An application's log may record a proxy address or a forwarded value, which is not automatically the value used by the custom rule. Check the hostname and path too, including any earlier rewrite. Change one condition at a time so you can identify the cause of a different result.
Review Events and Remove Stale Rules
Open the Events tab on the Analytics page for the domain. Filter by the relevant address, action, hostname, and time, then inspect the rule details in each matching event. Security Events covers requests that security features acted on or flagged, rather than providing a complete access log. Sampling can omit individual events, so an empty result does not prove that no request occurred.
Reassess the rule when the incident ends, the address is reassigned, or legitimate visitors report being blocked. Disable or remove a temporary rule when it is no longer needed, then repeat the affected request. If the request remains blocked, inspect the new event before changing anything else; a different security rule or the application itself may still be refusing access.







