DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk11 min

How to Block an IP Address in WordPress (Wordfence, .htaccess, and Cloudflare)

Block abusive WordPress traffic safely with Wordfence, Apache .htaccess, or Cloudflare. Follow exact steps, understand CIDR ranges, avoid proxy mistakes, and recover from bad rules.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To block an IP address in WordPress, use Wordfence for a quick plugin-level block, an Apache .htaccess rule for server-level control, or a Cloudflare firewall rule when your site is proxied through Cloudflare. Choose one enforcement point, confirm the address you intend to block, and keep a recovery path so you do not lock out legitimate visitors or yourself.

Which WordPress IP-blocking method should you use?

The right method depends on where you want the request rejected and what infrastructure your site uses. Wordfence is the least technical option. An Apache rule acts before WordPress loads and is useful for a small list or a range of addresses. Cloudflare can reject traffic at its edge, before it reaches your hosting server, but only when the domain is proxied through Cloudflare.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Method Where the block happens Best use Main risk or limitation
Wordfence Blocking Inside the WordPress security plugin One or a few abusive addresses; temporary blocks; sites already running Wordfence WordPress and the plugin still receive the request, so it consumes some server resources
.htaccess Apache web server, before WordPress Server-wide blocks and CIDR ranges on Apache hosting A syntax error can produce a 500 error; rules can match the wrong address behind a proxy
Cloudflare firewall Cloudflare’s edge, before the origin server Proxied sites receiving repeated unwanted traffic or broad attacks It does nothing for DNS-only traffic, and dashboard labels can change

Do not combine methods automatically. A single, correctly placed rule is easier to test and remove. Layering can make sense for a persistent attack, but document each block so a future administrator knows where to undo it.

Before you block an IP address

Confirm that the address is genuinely abusive

Look for repeated failed logins, aggressive crawling, comment spam, exploit attempts, or a volume of requests that is clearly inconsistent with normal use. A single suspicious request is not always enough: shared offices, schools, mobile carriers, and virtual private networks can put many unrelated people behind one public address.

Use Wordfence’s live traffic log, your hosting access log, or Cloudflare’s request analytics to identify the address and the pattern associated with it. Check the timestamp, requested URL, response code, and user agent where available. Block the address only after you have ruled out a misconfigured plugin, a search crawler you need, or your own monitoring service.

Record your own access addresses

Write down the public IP address you use to administer the site, plus the address used by a trusted colleague or office. If your internet provider changes your address regularly, do not rely on a permanent allowlist entry as your only protection. Keep a second administrator account and an out-of-band way to reach the hosting file manager or control panel.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Decide whether you need a single address or a range

  • Single address: use the exact IPv4 or IPv6 address when the abuse is isolated.
  • Range: use a CIDR range only when you have evidence that multiple addresses in the same allocation are involved. A broad range can block legitimate users.
  • Temporary block: prefer this when the source may be a compromised device, a short-lived bot, or an address shared by many people.

Back up before editing server configuration

For a server-level rule, download a copy of the existing .htaccess file before changing it. Save the file with its original name and keep the backup outside the public web directory. If the site becomes inaccessible, you can restore the original through the hosting file manager, FTP, or another server access method.

How to block an IP with Wordfence

Wordfence is usually the safest starting point when the site already has the plugin installed and you need to block a small number of addresses. The block is managed from WordPress rather than from the hosting server.

Block one address temporarily or permanently

  1. Sign in to the WordPress administrator dashboard.
  2. Open Wordfence > Firewall > Blocking.
  3. Find Manually Block IPs.
  4. Enter the complete IP address. Check every character before submitting; an extra digit can block a different address or fail to match.
  5. Choose Permanent or select a temporary duration, such as one hour or one day.
  6. Apply the block and confirm that it appears in the active-block list.

A temporary block is appropriate when you are testing a rule or dealing with an incident that may stop on its own. A permanent entry should be reserved for an address you have a continuing reason to deny, because public addresses can later be reassigned.

Block a range in Wordfence

  1. Remain on Wordfence > Firewall > Blocking.
  2. Open Block by IP Address Range.
  3. Enter the range in the notation the screen accepts, then review the first and last addresses represented by that range.
  4. Submit the rule and check the resulting entry in the list of blocks.

Range blocking is more powerful than blocking one address, but it also increases the chance of denying legitimate visitors. Start with the narrowest range that explains the observed traffic.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Find the address from live traffic

When you do not know which address to block, open the Wordfence live traffic view and filter the recent requests. Use the request details to distinguish repeated malicious activity from a normal user who simply triggered an error. Copy the address directly from the log instead of retyping it.

Remove or change a Wordfence block

Return to the Blocking screen, locate the active entry, and use its remove or unblock control. If a temporary block was selected, it should disappear when its duration expires. After removing a rule, watch the live traffic log to confirm whether the underlying activity has stopped; deleting the block does not fix a compromised account or vulnerable endpoint.

How to block an IP with WordPress .htaccess

This method applies to sites served by Apache. The .htaccess file is commonly in the site’s public_html directory or the document root that contains wp-admin, wp-content, and wp-includes. If your server runs Nginx, an .htaccess file is not the place to configure access rules; ask the host for the equivalent server configuration instead.

Use Apache 2.4 syntax for a single IPv4 address

  1. Open the hosting file manager or connect with FTP/SFTP.
  2. Enable the option to show hidden files, because filenames beginning with a period may be hidden.
  3. Download a backup of .htaccess.
  4. Edit the existing file without deleting WordPress’s rewrite rules.
  5. Add the deny rule in the access-control section, replacing the example address with the one you verified.
Require not ip 203.0.113.42

Apache 2.4 uses the Require syntax. The example address belongs to a documentation-only range; substitute the real address you intend to block. Keep the rule syntactically separate from WordPress’s RewriteEngine and RewriteRule lines.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand the older Deny from form

Older Apache configurations commonly use a Deny from directive. It may continue to work through Apache’s compatibility module, but it is legacy syntax rather than the preferred Apache 2.4 form. If your host supplies a generated access-control template, follow that environment’s documented syntax instead of mixing directive styles at random.

Block a CIDR range

CIDR notation expresses a network prefix and its size. A /32 IPv4 range contains one address. A /24 contains 256 IPv4 addresses, so a rule for a /24 can affect many unrelated visitors. Use the smallest prefix that covers the confirmed abusive allocation.

Require not ip 203.0.113.0/24

Do not assume that adjacent addresses belong to the same attacker. Check the log pattern and the address allocation information available from your host or network operator before choosing a broad range.

Save and test the change

  1. Save the file and preserve its permissions and encoding.
  2. Open the site in a normal browser from an address that should remain allowed.
  3. Test the login page, a representative front-end page, and an administrator page.
  4. Review the server error log if any page returns a 500 status.

If the site immediately returns a 500 error or becomes unreachable, restore the backup first. A malformed directive, unsupported module, or misplaced rule can break the entire virtual host. Do not keep editing a broken file through the browser-based WordPress editor.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to block an IP with Cloudflare

Cloudflare can reject a request at its edge, so the origin server never handles the blocked request. This is useful when unwanted traffic is consuming bandwidth or connection capacity, not merely WordPress CPU time. The domain must be proxied through Cloudflare; a DNS-only record sends traffic directly to the origin and cannot apply an edge firewall block.

Create an IP firewall rule

Guides commonly describe this dashboard path: Firewall > Firewall Rules > Create a Firewall Rule. Cloudflare changes product names and navigation periodically, so confirm the current labels in your account before publishing a rule.

  1. Sign in to the Cloudflare dashboard and select the correct zone.
  2. Open the firewall or security rules area.
  3. Create a rule that matches the visitor IP address you confirmed in your logs.
  4. Set the action to block, review the scope, and give the rule a descriptive name such as the incident date and reason.
  5. Deploy the rule and monitor security events to verify that matching requests are being stopped.

Use a separate rule for each unrelated address when clarity matters. If several addresses are part of one confirmed network range, use the narrowest range that explains the attack. Avoid copying a range from an unverified list: an edge block affects every visitor whose request matches it.

Check whether Cloudflare is actually in the request path

The block is effective only for hostnames whose DNS records are proxied. If visitors can reach the origin through an unproxied hostname or a disclosed origin address, they may bypass the edge rule. Protecting the origin requires separate network or server controls, and those controls must account for the proxy arrangement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Cloudflare and .htaccess trap

When a site is behind Cloudflare, the origin web server can see Cloudflare’s connecting addresses rather than the visitor’s original address. A server-level rule that was written for the visitor’s IP can therefore match the wrong value. In the worst case, it can block Cloudflare itself, stop Wordfence from receiving useful visitor information, or deny your own requests.

Do not paste Cloudflare’s published network ranges into .htaccess as a substitute for restoring the visitor address. A WordPress.org support discussion describes a case in which allowlisting a home address and Cloudflare ranges in .htaccess was followed by a Wordfence interface that stopped updating. Treat that symptom as a sign to review the proxy and real-client-IP configuration rather than adding more addresses blindly.

  • For a proxied site, prefer the Cloudflare edge rule for visitor-IP blocking.
  • Use .htaccess for rules based on information the origin can reliably see, and verify the logged address first.
  • If Wordfence logs show proxy addresses instead of visitors, pause the block and have the hosting or proxy administrator correct the trusted-proxy configuration.

Verify that the block works without locking yourself out

Check the expected result

  • The blocked address should receive the action selected by the enforcement layer: a Wordfence block response, an Apache denial, or a Cloudflare block page.
  • An allowed address should still load the home page, login page, and a normal content URL.
  • The relevant log should show the request and the rule that handled it.

Use a controlled test

Do not test a permanent rule while connected through the only administrator connection you have. Schedule the change, keep the hosting file manager open in a separate session, and use a second trusted connection for verification. If your public IP changes during testing, update your notes before interpreting the result.

Remove the rule if legitimate traffic is affected

For Wordfence, remove the entry from the Blocking screen. For Cloudflare, disable or delete the matching firewall rule. For Apache, restore the backed-up file or remove only the new directive, then retest. Record what was changed and why so the same address is not accidentally reblocked by another layer.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failures

The block does nothing

  • Confirm that the address in the rule is the address recorded at the same enforcement layer.
  • Check whether the visitor is rotating addresses through a mobile connection, proxy, or botnet.
  • Verify that Cloudflare is proxied for the hostname receiving the traffic.
  • Look for another hostname, direct origin address, or API endpoint that bypasses the rule.

The site returns “500 Internal Server Error” after an .htaccess edit

Restore the backup immediately through the hosting file manager or FTP/SFTP. Then inspect the server error log and confirm whether the host supports Apache 2.4 Require directives and the module needed for legacy syntax. Reapply one rule at a time only after the site is stable.

Legitimate visitors are blocked

Remove the broad range and replace it with the specific address or a shorter-lived block. Shared networks make permanent IP denial especially risky. If the traffic is an authentication attack, protect the login endpoint rather than denying an entire organization or country based on one address.

Wordfence traffic information suddenly looks wrong

Review recent proxy, DNS, and .htaccess changes. A server that records Cloudflare addresses instead of client addresses cannot reliably support visitor-IP rules at the origin. Temporarily disable the suspect rule, restore the last known-good configuration, and involve the host or proxy administrator before creating another allowlist.

Why IP blocking is not a complete security strategy

An IP address identifies a network endpoint at a moment in time, not a person. Attackers can rotate addresses, use residential proxies, compromise new devices, or move to a different network. A block can reduce noise from a known source, but it does not repair a vulnerable plugin, stolen password, exposed XML-RPC endpoint, or weak login policy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Pair an IP block with controls appropriate to the behavior you observed:

  • Use login-rate limiting and multi-factor authentication for administrator and editorial accounts.
  • Keep WordPress core, themes, and plugins updated and remove software you no longer use.
  • Use strong, unique passwords and review administrator accounts for unexpected changes.
  • Rate-limit comment, registration, search, and API endpoints that attract automated abuse.
  • Monitor logs after the block to determine whether the same behavior moves to new addresses.
  • Maintain tested backups so a bad rule or a compromise does not become a permanent outage.

Use the narrowest, shortest-lived block that solves the immediate problem, then address the control that allowed the abuse to reach the site.

A practical decision checklist

Your situation Recommended first action What to verify
One known address is repeatedly probing a WordPress site Wordfence temporary or permanent block The live traffic entry and the resulting block record
Several addresses in a confirmed network are attacking an Apache origin A narrow Apache CIDR rule after backing up .htaccess Apache version, syntax support, and a clean response from an allowed connection
Traffic is overwhelming a site already proxied through Cloudflare Cloudflare firewall rule at the edge That the hostname is proxied and security events show the rule firing
The site is behind Cloudflare and origin logs show proxy addresses Do not add visitor-IP rules to .htaccess yet; correct address handling first That logs and Wordfence identify the real client address consistently
Abuse continues from changing addresses Keep a narrow temporary block, then add rate limits, login protections, and updates Whether the behavior stops rather than merely moving to another IP

Final recommendation

Start with Wordfence when you need a reversible block and already use the plugin. Choose .htaccess when Apache must reject a verified address or range before WordPress runs, and always keep a backup. Choose Cloudflare when the site is proxied and the traffic should be stopped at the edge. The most important operational rule is to match the blocking layer to the address it can actually see; behind a proxy, a technically correct-looking IP rule can otherwise block the wrong system.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.