How to protect the WordPress login page against brute-force attacks
What best protects a WordPress login is a combination of three things: a long, unique password, two-factor authentication (2FA), and a limit on login attempts per IP address. The other measures, such as changing the login page address, blocking countries, or adding a CAPTCHA, reduce the noise and the volume of automated attacks, but none of them alone stops an attacker who has the correct password.
This article explains how to recognize a brute-force attack and shows, measure by measure, what each one does, how to set it up, and where it doesn’t help. Menu and plugin names vary depending on the WordPress and cPanel versions, so use the paths below as a reference, not as exact text.
What is a brute-force login attack?
A brute-force attack is a bot trying to get into your site by guessing username and password combinations, thousands of times, with no one watching. It doesn’t pick your site for any particular reason: every WordPress site has the same login page (yourdomain.com/wp-login.php) and the same admin area (/wp-admin), and bots scan the internet looking for them. Being small or unknown doesn’t protect you.
Bots usually try common usernames (admin, the domain name, the company name) and passwords from leaked lists from other services. Anyone who reuses the same password in several places is the easiest target, because the bot may already have the right password.
How to tell that your login is under attack
These are the most common signs:
- Site slow or down for no clear reason. Each login attempt makes the server query the database. Many attempts per minute add up.
- “Login attempt” or lockout emails sent by a security plugin, if you have one.
- Requests to
/wp-login.phpor/xmlrpc.phpin large numbers in the access logs. In cPanel, the logs are under “Raw Access” or “Access Logs”. Look for many lines withPOST /wp-login.phpcoming from different IP addresses within a few minutes. - A locked-out user or a password that “no longer works” right after several attempts.
- An administrator user you didn’t create. This sign means someone has already gotten in. If so, go to the article Signs that your site was hacked.
Seeing attempts in the logs does not mean your site was hacked. It is normal background noise for any site on the internet. The warning sign is when the volume suddenly rises, or when an attempt succeeds.
Measure 1: change the “admin” username and use a strong password
This is the measure with the best cost-benefit, because it targets how most login breaches happen.
- In the WordPress dashboard, open Users and check the administrators.
- If there is a user named
admin(or the domain name), create a new administrator with a name that isn’t obvious and with a different email address of yours. - Log in with the new user, open Users, choose the old one, and delete it. When WordPress asks what to do with its content, assign it to the new user.
- Set a long password (preferably a passphrase of 16 characters or more), different from any other you use, and store it in a password manager.
- Check the “Display name” field. It appears publicly on posts and shouldn’t be the same as the login username.
Limit: the username isn’t a secret. WordPress can reveal it on author pages (?author=1) and on some public routes. So an uncommon username helps, but the password is what actually holds the door. For care with passwords across the whole site, see Site passwords and access.
Measure 2: turn on two-factor authentication (2FA)
With 2FA, the correct password is not enough: the login also asks for a code generated on your phone. Even if the password leaks or is guessed, the attacker stops at the second step.
The step-by-step guide for the hosting panel and for WordPress is in Two-step verification in cPanel and WordPress. If you need to install a plugin for this, see How to install a plugin in WordPress.
Limit: 2FA protects the login, but it doesn’t protect against a vulnerable plugin or against a session that has already been stolen. Store the recovery codes somewhere safe: without them, losing your phone can lock you out.
Measure 3: limit login attempts
Limiting attempts temporarily blocks the IP address that gets the password wrong several times in a row. This stops the bot that tests thousands of passwords, because it is left with only a few tries at a time.
- Install a plugin that limits login attempts. There are dedicated options, and full security plugins that include this feature. The feature’s name varies (limit login attempts, login lockout, brute-force protection).
- Set a low number of failed attempts allowed (for example, 3 to 5) and a lockout time that grows with each repeat offense.
- Run a test: log out, enter the wrong password on purpose until the lockout appears, and check whether the message and the time are as you configured.
- Note how to unblock your own IP, in case you get locked out yourself.
Limit: more sophisticated bots switch IP addresses with every attempt and get around a limit per address. There is also a risk of unfair blocking: a whole team behind the same company IP can lock itself out by mistake.
Measure 4: change the login page address
Plugins let you replace /wp-login.php with another path, such as /internal-entrance. For the common bot, which only tries the default address, the page “disappears.” The practical result is fewer attempts in the logs and less load on the server.
What this does not do: it is not real protection against someone who is deliberately looking for your site. The new address can leak through an old link, a password-reset email, or a plugin that repeats it. And other doors stay open, such as /xmlrpc.php (see below). Treat changing the address as an add-on that reduces noise, never as a replacement for a strong password, 2FA, and attempt limits.
If you use it, keep these precautions in mind:
- Write the new address down in a password manager.
- Test it in a private window before you leave your current session.
- Know that some caching, membership, or store plugins depend on the default address. Test customer logins, if you have any.
Measure 5: block by IP or by country, carefully
If your site only serves Brazil, blocking access to the login area from other countries cuts off much of the automated attack. If only you and your team log into the dashboard and you have fixed IP addresses, you can allow only those addresses.
Before turning this block on, weigh these risks:
| Situation | Risk |
|---|---|
| Blocking entire countries | You may block yourself when traveling, using a VPN, or working with someone abroad |
| Allowing only your own IP | Home internet providers change IP addresses; you may get locked out |
| Blocking only the login | Doesn’t prevent attacks on other parts of the site |
| Country-based blocking | The location of an IP address isn’t exact, and attackers use servers in Brazil |
When you set it up, apply the rule only to /wp-login.php and /wp-admin, not to the whole site, or you will block legitimate visitors. Always keep a second way in (the hosting panel) so you can undo the rule.
Measure 6: disable XML-RPC if you don’t use it
xmlrpc.php is an old WordPress feature that lets apps and services talk to the site. It accepts logins, and one of its methods allows many password attempts to be sent in a single request. That makes attacks more efficient and can get around plugins that only watch wp-login.php.
Today, most sites don’t need it. But some services still use it, such as certain integrations and the old WordPress mobile app, so disable it with a test:
- Check the access logs for many requests to
POST /xmlrpc.php. - Disable XML-RPC with a security plugin that offers the option, or with a rule on the server. If you don’t know how, ask support.
- Test what depends on it: integrations, publishing apps, remote backup plugins.
- If something stops working, turn it back on and check whether that service can use the WordPress REST API, which is the current alternative.
Limit: disabling XML-RPC closes one door, not all of them. wp-login.php still needs the earlier measures.
Measure 7: CAPTCHA on the login form
A CAPTCHA asks the visitor to prove they are not a bot before the login is submitted. There are plugins that add it to the login form, the signup form, and the comments form, with options that don’t require “clicking on traffic lights.”
Limit: it filters out simple bots, but there are services that solve CAPTCHAs in bulk. A poorly chosen one also frustrates legitimate users and people with visual impairments. Pick an option that respects privacy, and check that it doesn’t load third-party fonts or scripts you don’t want on your site.
Measure 8: protect /wp-admin with a password in cPanel
cPanel lets you require a second password, set on the server, before opening a folder. That way, a visitor only reaches the WordPress form after passing this first barrier. The feature is called “Directory Privacy” or “Directory Protection,” depending on the cPanel theme.
- In cPanel, open the File Manager or the “Directory Privacy” feature.
- Navigate to the site folder (usually
public_html) and choose thewp-adminfolder. - Check the option to protect the directory with a password, and give the protected area a name.
- Create a username and password that are different from your WordPress ones.
- Save, then open
yourdomain.com/wp-adminin a private window. The browser should ask for the username and password before showing anything.
Important limits:
- The
wp-login.phpfile sits outside thewp-adminfolder, so protecting that folder does not protect the login form itself. To cover it, you need a specific rule for that file, or another measure from this article. - Some features on the public site use the
wp-admin/admin-ajax.phpfile. With the whole folder protected, forms and filters that depend on it may stop working for visitors. If that happens, the exception has to be allowed. That requires adjusting the.htaccessfile, which should be done carefully and with a backup copy of the file saved. - If more than one person logs into the dashboard, everyone needs the second password.
And what does the hosting firewall do?
MigraCloud uses cPGuard, which works as a firewall and automatically cleans up and quarantines suspicious files, with alerts by email. It is one more layer on the server, but it does not replace the measures in this article and does not promise to block every attack: a weak password that the attacker guesses correctly is still a correct password. If you receive a cPGuard alert about your site, read it carefully, and if you have questions, contact us.
Suggested order of application
- Long, unique password, and replace the
adminusername. - 2FA for all administrators.
- A limit on login attempts.
- Disable XML-RPC, if nothing uses it.
- Optional, depending on your case: CAPTCHA, restriction by IP or country, changing the login address, and directory protection.
Also keep WordPress, plugins, and themes up to date, and keep a site backup outside the server. If the worst happens, that copy is what lets you go back.
Frequently asked questions
Does changing the wp-login.php address make the site secure?
Not by itself. It reduces attempts from bots that only test the default address, but it doesn’t stop a targeted attack, and the new address can leak. Use it as a complement to a strong password, 2FA, and attempt limits.
Do I need to change the “admin” username?
It’s recommended. admin is the first name bots try. Changing it doesn’t replace a strong password, because usernames can be discovered, but it removes the easiest guess.
How do I know if my site is under a brute-force attack?
Check the access logs for many POST requests to /wp-login.php or /xmlrpc.php in a short time, coming from different IP addresses. Unexplained slowness and blocking alerts from security plugins are also signs. Isolated attempts are normal. Spikes, and successful logins that you didn’t make, deserve investigation.
Can I block every country except Brazil?
Yes, applying the rule only to the login and the admin area. Remember that location by IP isn’t exact, that you may block yourself when traveling or using a VPN, and that attackers also use servers in Brazil. Always have another way to undo the rule.
Does disabling XML-RPC break my site?
On most sites, no. But integrations, publishing apps, and some backup plugins or plugins that connect to external services still use it. Disable it, test those features, and turn it back on if something stops working.
Is it worth protecting /wp-admin with a password in cPanel?
It is worth it as an extra layer, if you are fine with entering a second password and can handle the admin-ajax.php exception. Remember that the wp-login.php form sits outside that folder, so directory protection alone does not cover the login.
Is a login attempt limit plugin enough?
It helps a lot against bots that test many passwords, but not against weak passwords guessed on the first or second try, or against attacks that switch IP addresses with every request. Combine it with a strong password and 2FA.
What should I do if someone has already gotten into my dashboard?
Change the passwords of all administrators, of the hosting account, and of the database. Review the list of users and plugins, and follow the steps in Signs that your site was hacked. If there is malware, removal by a professional is usually the fastest path.