🛡️
Security

Protecting wp-login.php from brute-force attacks

19.11.2026
← All articles

Every WordPress site has its login page at wp-login.php, and every bot knows it. Each day they hit thousands of sites and try username and password pairs one after another. Most owners only notice when the site slows down or the host warns about resource limits, yet a few simple settings make these attacks almost useless.

How the attack works

Bots either cycle through common passwords such as 123456 or admin2024, or replay credentials leaked from other sites, which succeeds instantly if an admin reused a password. A successful login leads to fake admin accounts, malicious plugins, hidden links and redirects. Even failed attempts cost PHP and database work, and thousands of them slow the site for real visitors.

The key point is that no single measure is enough. A login limiter does not help much against a botnet that sends one attempt from each of ten thousand addresses, and a strong password does nothing about the server load. The approach below therefore combines account hygiene, attempt limits and a server-level barrier, so that the attack fails on several fronts at once and your hosting resources are spent on real customers instead of bots.

Example: a furniture shop in Andijan

A furniture shop in Andijan sells through a WooCommerce site on misol.uz. For a week the site crawled every evening and the host warned about resource usage. The logs showed thousands of POST requests per hour to wp-login.php from hundreds of addresses, and the admin username was simply admin. After renaming the account, installing a login limiter and adding a server password to wp-login.php, the attempts stopped reaching PHP and speed returned to normal.

Spotting the attack in your logs

grep "POST /wp-login.php" access.log | awk '{print $1}' | sort | uniq -c | sort -rn | head -20

A normal site sees a few dozen logins a day. Hundreds from one address mean an attack, but modern botnets also spread attempts across thousands of IPs, so blocking addresses alone is not enough.

Clean up admin accounts

Drop usernames like admin. WordPress cannot rename a login in the dashboard, so create a new admin and remove the old one with WP-CLI:

wp user list --fields=ID,user_login,roles
wp user create bosh_menejer menejer@example.uz --role=administrator
wp user delete 1 --reassign=2

Use the IDs from wp user list; --reassign moves the old account's posts to the new one. Set unique passwords of 14 or more characters and enable two-factor authentication. Usernames also leak through /?author=1; in Apache you can block that outside the dashboard:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/wp-admin
RewriteCond %{QUERY_STRING} (^|&)author=[0-9]+ [NC]
RewriteRule ^ - [F]

Limit login attempts

Login limiter plugins lock an address out after several wrong passwords, but every request still loads WordPress. On Nginx, rate limiting stops floods before PHP:

limit_req_zone $binary_remote_addr zone=wplogin:10m rate=5r/m;

location = /wp-login.php {
    limit_req zone=wplogin burst=3 nodelay;
    # your usual PHP handling directives here
}

The first line belongs in the http block. On a VPS, a tool such as fail2ban can also ban attacking IPs at the firewall.

Add a server password to wp-login.php

Create a password file with htpasswd -c ~/.htpasswds/wp.htpasswd ishchi and add this to .htaccess:

<Files "wp-login.php">
    AuthType Basic
    AuthName "Restricted"
    AuthUserFile /home/user/.htpasswds/wp.htpasswd
    Require valid-user
</Files>

Skip this if customers log in through wp-login.php, and rely on attempt limits and 2FA instead. Remember that password guessing also goes through xmlrpc.php. On sayt.uz hosting these files can be edited in the ISPmanager file manager opened from your cabinet.

Related articles

🔑 Password Policy for Website Users: Modern Rules That Work 🚫 Your IP Is Blacklisted: How to Get Delisted from Spamhaus 🔐 Hiding and protecting your admin panel: a layered approach 🚫 xmlrpc.php: should you disable it, and how to do it safely
🌐 Language
🇺🇿 O'zbek 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓