Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared Managed Cloud India
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Best lists Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Security · Guide

How to Protect WordPress From DDoS Attacks

Short answer

Protect WordPress from DDoS attacks by putting Cloudflare in front of the site, rate limiting wp-login.php and other costly pages, caching what you can, and switching on Under Attack mode while an attack runs. Cloudflare's DDoS protection is automatic on all plans, including free. A plugin firewall alone cannot absorb a flood, so the edge layer matters most.

Key takeaways

  • A DDoS attack floods a site with requests from a botnet until real visitors cannot get through.
  • Cloudflare's DDoS protection is automatic on all plans, including free, once DNS is proxied.
  • The free plan allows 1 rate limiting rule with a 10 second window, counted by IP.
  • Under Attack mode is a last resort: it challenges visitors and decides within five seconds.
  • The average WordPress site is attacked once every 33 minutes, according to Wordfence.

What is a DDoS attack on WordPress?

A DDoS attack floods a WordPress site with so many requests that real visitors cannot get through.

Sucuri defines a DDoS attack as flooding a service with a large amount of traffic, often using a botnet: a network of compromised devices or computers. Sucuri notes that around 2,000 DDoS attacks occur globally every day, and that a small attack can cost an attacker as little as $10.

Attacks hit at different layers. Cloudflare's docs split protection across network layer attacks at layers 3 and 4 and application layer attacks at layer 7, as listed in its DDoS protection docs.

Application layer attacks are the common threat for WordPress. A single HTTP request to an uncached page can cost real PHP time, so a flood of them can take a small site down fast. Sucuri notes that one machine targeting a site's search feature can take it down.

Attacks are not rare. Wordfence reports the average WordPress site is attacked once every 33 minutes, with 44 requests a day probing for weak passwords and vulnerable plugins. See the numbers in website security statistics.

How do you know your WordPress site is under attack?

A sudden jump in requests, a slow or unreachable site, and a host warning about CPU or bandwidth usually mean an attack is running.

Check your host's resource graphs first. A normal site has a steady pattern, and an attack shows as a sharp spike in requests or CPU that does not match any post, sale or campaign.

Look at the access log for the same signs: one IP or a small group of IPs sending hundreds of requests a minute, the same costly URL hit again and again, or a flood of POST requests to wp-login.php and xmlrpc.php.

Wordfence Live Traffic shows visits and hack attempts in real time, including the origin IP, the time and the URL. Its plugin page notes it also watches disk space, since many DDoS attacks try to consume all disk space.

Do not guess from a single slow page. Compare the traffic against a normal day, and check whether your host has flagged the account for resource use.

What should you set up before an attack?

Put Cloudflare in front of the site, turn on its DDoS protection, and add a rate limiting rule for the login page before anything happens.

Cloudflare's DDoS protection detects and mitigates attacks automatically, and it is available on all plans. Its docs state the standard unmetered protection across layers 3 to 7 runs on the free plan too.

Point your domain's DNS at Cloudflare and make sure the records are proxied, so traffic passes through Cloudflare first. An unproxied record lets attackers hit your server IP directly and skip every rule you set.

Add a plugin firewall as a second layer. Wordfence runs inside WordPress, so it can use the visitor's login state in its rules, and its free version includes a firewall and a malware scanner.

Keep a backup from before the attack. If an attack hides a break-in, a clean backup is what lets you rebuild. See the guide to set up the Wordfence firewall for the plugin side of this setup.

How do you turn on Cloudflare's DDoS protection?

You do not need to turn it on: Cloudflare's DDoS systems detect and mitigate attacks automatically once your DNS is proxied through Cloudflare.

The protection uses managed rulesets that cover network layer attacks at layers 3 and 4 and application layer attacks at layer 7, according to Cloudflare's DDoS protection docs. You can tune the rules in a ruleset, and the free plan allows 1 ruleset override.

Check the setup in the Cloudflare dashboard:

  1. Open your zone and confirm the DNS records show as proxied.
  2. Open Security, then DDoS, and confirm the HTTP and network-layer protections show as active.
  3. Check that your origin IP is not listed anywhere public, such as in old DNS history or a mail record.

Sucuri lists the standard defenses as a web application firewall, rate limiting, caching, traffic monitoring and moving to the cloud. For a WordPress site, rate limiting and the firewall are the two you will use most.

How do you rate limit wp-login.php and other hot spots?

Create a rate limiting rule that blocks or challenges an IP after too many requests to one URL in a short window.

Rate limiting rules cap how many requests one IP can send to a matching URL before Cloudflare acts. The rate limiting docs list the settings: the expression, the counting characteristic, the period, the requests per period, and the mitigation timeout.

On the free plan you get 1 rule, with a 10 second counting period and a 10 second mitigation timeout, counted by IP. The Pro plan allows 2 rules, and Business allows 5.

Cloudflare planRate limiting rulesCounting period
Free110 seconds
Pro2Up to 1 minute
Business5Up to 10 minutes

Set the first rule on the login page:

  1. In the Cloudflare dashboard, go to Security, then Security rules.
  2. Create a rate limiting rule for the URI path /wp-login.php.
  3. Set the limit to 5 requests per IP in 10 seconds, with a Block action for 10 seconds.

Add the same treatment to other costly URLs: the search page, xmlrpc.php, the cart page on a shop, and any form endpoint that bots hammer. On the free plan, one rule means choosing the worst URL first, usually wp-login.php.

Cloudflare warns that rate limiting is not exact: there can be a delay of a few seconds between detecting a request and updating the counters, so some extra requests can still reach the origin.

What do you do while an attack is happening?

Switch on Under Attack mode first, then watch the traffic and tighten the rules on the URLs that are being hit.

Cloudflare's Under Attack mode performs extra security checks to mitigate layer 7 DDoS attacks. Visitors see an interstitial page, validated users get through, and suspicious traffic is blocked. Its docs call the mode one of the last resorts when a zone is under attack.

Turn it on in the dashboard: select your zone, then switch on Under Attack Mode in the Quick Actions sidebar. The challenge decides whether to block or allow a visitor within five seconds, according to the Under Attack mode docs.

While it is on, do these three things:

  • Watch the Cloudflare analytics for the top IPs, user agents and paths.
  • Add a custom rule or a rate limiting rule for the exact path the attack targets.
  • Tell your host, since the host can see whether the flood is reaching the origin.

Under Attack mode needs JavaScript, so it affects some analytics and API traffic. It also pauses normal access briefly, so use it during an attack, not as a permanent setting.

How do you recover after the attack ends?

Turn Under Attack mode off, check that real visitors can reach the site, then scan for damage and keep the rules that helped.

Switch the mode off in the same Quick Actions sidebar. Then open the site in a private window and confirm pages load, the login works, and forms submit.

Run a full malware scan. Wordfence's scanner compares core files, themes and plugins against the WordPress.org repository and checks for more than 44,000 known malware variants. An attack can hide a break-in, so a clean scan matters.

Check the logs for what happened. Note the IPs, the URLs and the time window, and keep the rate limiting rule that stopped the worst of it. If the attack targeted one plugin or endpoint, update or replace it.

Update WordPress, plugins and themes after the attack. WordPress 7.1.4 was released on 28 October 2026 as a security release, according to Wordfence, so running the latest release matters right after an incident.

What mistakes should you avoid?

The common mistakes are leaving Under Attack mode on forever, trusting a plugin firewall to absorb a flood, and exposing the origin IP.

Avoid these five:

  • Leaving Under Attack mode on for weeks, which blocks real visitors and breaks analytics
  • Relying only on a plugin firewall, which still lets the flood reach your server
  • Leaving a DNS record unproxied, so attackers can hit the origin directly
  • Rate limiting the whole site instead of the costly URLs, which blocks real visitors
  • Ignoring the attack after it stops, without scanning for a break-in

A plugin firewall is still worth having. Wordfence notes its firewall uses the visitor's login state in more than 80% of its rules, which a cloud firewall cannot see. Use both layers, with the cloud layer taking the flood.

If the site keeps falling over under normal traffic, the hosting plan may be too small. See how many visitors shared hosting can handle before deciding whether to move.

Frequently asked questions

Does Cloudflare protect WordPress from DDoS on the free plan?

Yes. Cloudflare's standard DDoS protection is automatic on all plans, including free, once your DNS is proxied through Cloudflare. The free plan also includes 1 rate limiting rule with a 10 second window for your worst URL, such as wp-login.php.

Can a WordPress security plugin stop a DDoS attack alone?

It depends on the size of the flood. A plugin firewall runs on your server, so the flood still reaches it and uses your CPU and bandwidth. A cloud firewall filters the flood before it arrives, which is why the edge layer matters most for large attacks.

Should I leave Under Attack mode on all the time?

No. Under Attack mode shows every visitor a browser check, which needs JavaScript and pauses access briefly. Cloudflare calls it one of the last resorts during an attack, so switch it off once the attack ends.

How can I tell a DDoS attack from a traffic spike?

Check your host's CPU and request graphs for a sharp spike, then look at the access log for repeated requests to one URL or a flood of login attempts. A single slow page is usually a caching or plugin problem, not an attack.

What should I update after a DDoS attack?

Yes. WordPress 7.1.4 was released on 28 October 2026 as a security release. Update core, plugins and themes after an attack, and run a full malware scan, since an attack can hide a break-in.

Sources

  1. How to Prevent a DDoS Attack Sucuri
  2. DDoS Protection Cloudflare
  3. Under Attack mode Cloudflare
  4. Rate limiting rules Cloudflare
  5. Wordfence Wordfence
  6. Hardening WordPress WordPress Developer Resources

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

WPLegible editors

Researched from the primary sources listed above and checked against our editorial rules. About the site · How we test