Skip to main content
Security

How to Harden Your WordPress Login Page Against Bots

MMercy Chepkemoi19 November 202616 min read7 views

Put a brand-new WordPress site online and check its access logs a few hours later. Almost certainly, you will find strangers already knocking on the door: dozens or hundreds of requests to wp-login.php, trying common usernames and passwords. They are not people. They are bots, scanning the internet for WordPress sites and trying their luck.

Most of these attempts fail. But they cost you something even when they do: server resources, slower pages, noisy logs and the constant risk that one weak password gives an attacker the keys to your whole website.

This guide shows you how to harden your WordPress login page against bots in layers: strong credentials, two-factor authentication, login limits, bot checks, restricting sensitive files, closing common loopholes and watching your logs. Start with the quick wins, then add the rest as your site grows.

Key takeaways

  • Bots attack WordPress logins constantly, using brute force, stolen password lists (credential stuffing) and guesses based on usernames they can discover.

  • No single fix is enough. Combine strong unique passwords, two-factor authentication, login attempt limits, bot protection and a firewall.

  • Two-factor authentication is the single most effective step against stolen or guessed passwords.

  • Block or restrict xmlrpc.php if you do not use it, and prevent your usernames from leaking.

  • Hiding or renaming the login URL reduces noise, but it is not real security on its own.

  • Always keep a safe way back in, such as SFTP or your hosting control panel, before you lock anything down.

  • Watch your logs and resource usage, because a login attack often shows up as slowness before anything else.

How Bots Attack WordPress Logins

Understanding the attacks makes the defences easier to choose.

  • Brute force: a bot tries many passwords for a username, one after another.

  • Credential stuffing: a bot tries email and password pairs leaked from other websites, hoping you reused yours. This works far better than random guessing.

  • Password spraying: a bot tries a few very common passwords across many usernames, to stay under lockout limits.

  • Username discovery: the bot finds real usernames first, for example from author archive pages, the REST API or different error messages, then targets them.

  • XML-RPC abuse: xmlrpc.php is an older remote-access interface. Attackers can use it to try many passwords in a single request, which bypasses simple login limits.

  • Registration and comment bots: where open registration is on, bots create fake accounts, which can then be used or abused.

These attacks are automated, relentless and cheap for the attacker, which is why your protection has to be automatic too.

Why It Matters

  • A successful login is a full compromise. An attacker with an administrator account can install malware, create hidden admin users, change your content and steal data.

  • Failed attempts still cost you. Login requests are never cached, so every attempt makes your server run PHP and query the database. A flood can push your account towards its resource limits, causing slowdowns and errors. See our guide to reading your cPanel resource usage.

  • Search and customer trust suffer if your site is hacked, defaced or used to send spam.

  • Personal data may be exposed. If your site holds customer information, a breach can trigger legal duties. Our guide to the Data Protection Act explains them.

The Layers of Login Protection

Layer

What it does

Effort

Strong, unique passwords

Makes guessing and reuse attacks fail

Low

Two-factor authentication

Stops a stolen password from being enough

Low to medium

Login attempt limits

Slows or blocks repeated failures

Low

Bot checks (CAPTCHA or similar)

Separates people from scripts

Low to medium

Firewall and rate limiting

Filters bad traffic before it reaches WordPress

Often provided by your host

Restricting access (IP rules, passwords)

Removes the login page from public reach

Medium

Closing loopholes (XML-RPC, user enumeration)

Removes easy side doors

Medium

Updates and least privilege

Reduces the damage and the entry points

Ongoing

Monitoring and alerts

Shows you attacks early

Ongoing

Step 1: Strong, Unique Passwords for Every Account

  • Use a password manager to create and store long random passwords, at least 14 to 16 characters.

  • Never reuse a password from any other site. Credential stuffing relies on reuse.

  • Let WordPress generate passwords for new users, and do not email passwords in plain text.

  • Remove or change any account that uses a weak or default password.

  • Do not use "admin" as a username (see Step 6), and avoid usernames that match your domain or company name.

For integrations that need access, such as apps and automation tools, use Application Passwords, a built-in WordPress feature, so each tool has its own credential that you can revoke without changing your main password.

Step 2: Turn On Two-Factor Authentication

Two-factor authentication (2FA) asks for a second proof of identity, usually a code from an authenticator app, in addition to the password. Even if a bot guesses or buys your password, it cannot log in without the second factor.

  • Install a reputable 2FA plugin. Several security plugins include one, and there are dedicated options such as the Two Factor plugin from WordPress contributors.

  • Prefer authenticator apps or security keys (passkeys) over text messages, which can be intercepted or redirected.

  • Require 2FA for administrators and editors first, then extend it to everyone who can publish or manage content, and customers' accounts on stores where appropriate.

  • Store backup codes safely, so that losing a phone does not lock you out.

  • Test the recovery process before you rely on it.

Step 3: Limit Login Attempts

Bots succeed by trying again and again. Limiting attempts takes that away.

  • Use a plugin that blocks or delays an IP address after a set number of failures, for example after five attempts in a few minutes, with increasing lockout periods. Many security plugins include this.

  • Set a sensible lockout, and make sure you can unlock yourself through email or by access to the server.

  • Watch out for attackers rotating through many IP addresses. Limits help, but they work best together with a firewall and 2FA.

  • On a VPS, server-level tools such as fail2ban can ban repeat offenders before WordPress even runs.

Step 4: Add a Bot Check to Login, Registration and Reset Forms

A bot check makes automated scripts fail while normal visitors pass.

  • Options include CAPTCHA services and modern challenge tools such as Cloudflare Turnstile, hCaptcha and Google reCAPTCHA, usually added through a plugin.

  • Protect the login, registration, password reset and comment forms, and the customer account forms on online stores.

  • Consider privacy and accessibility. Some services load third-party scripts and set cookies, so mention them in your privacy policy and check consent requirements. Offer an accessible alternative where you can.

  • Remember that a bot check is one layer, not a replacement for 2FA.

Step 5: Use a Firewall and Rate Limiting

A web application firewall (WAF) examines requests before they reach WordPress and blocks patterns that look malicious. Rate limiting caps how many requests one visitor can make in a given time.

  • Choose hosting with a firewall included. SteboHost includes a web application firewall, Imunify360 malware scanning and DDoS mitigation on every plan. See website security.

  • If you run your own server, you can add rate limiting at the web server. For example, in Nginx:

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

location = /wp-login.php {
  limit_req zone=login burst=5 nodelay;
  include fastcgi_params;
  # your PHP handler settings here
}

This allows about five login requests a minute per address, with a small burst. The limit_req_zone line belongs in the http block, and you must adjust the rest for your own PHP setup. Test with care so that you do not block real users.

Step 6: Stop Username Leaks

Bots find it easier to break in when they already know a valid username.

  • Never use "admin" or an obvious name. Create a new administrator with a different username, move the content across and delete the old account.

  • Use a different display name from your login name, so that your posts and comments do not reveal it.

  • Check author archive pages. Visiting yoursite.com/?author=1 can redirect to a page that shows a username. Plugins or rules can block this.

  • Review the REST API. WordPress can list public authors through its REST API. Restrict it if you do not need it, or use a security plugin that limits user listing.

  • Use a generic login error. By default, WordPress can show different messages for a wrong username and a wrong password, which tells bots which usernames exist. A small snippet in a must-use plugin or your child theme replaces it with one neutral message:

add_filter( 'login_errors', function () {
    return 'The username or password is incorrect.';
} );

If you are not comfortable adding code to your site, a security plugin can do this for you. Take a backup first and test on a staging copy.

Step 7: Close or Restrict XML-RPC

xmlrpc.php lets applications talk to WordPress remotely. Modern WordPress apps use the REST API instead, and most sites no longer need XML-RPC. Because it can accept many login attempts in one request, it is a favourite target.

If you do not use it, block it. On Apache-compatible servers, including LiteSpeed, add this to .htaccess:

<Files xmlrpc.php>
  Require all denied
</Files>

Some tools still rely on XML-RPC, including certain remote publishing and plugin integrations, so check before you block it and test afterwards. Many security plugins offer a switch that does the same thing.

Step 8: Restrict Who Can Reach the Login Page

The strongest option is to make the login page unreachable to everyone except your team.

Allow only trusted IP addresses

If you and your team log in from fixed addresses, such as an office, you can allow only those. Replace the example address with your own:

<Files wp-login.php>
  Require ip 203.0.113.10
</Files>

You can list several addresses or ranges on one line, separated by spaces. Do not use this if your IP address changes often, or if you travel and need access, because you could lock yourself out. Keep SFTP or control panel access ready so that you can remove the rule.

Add a second password layer

A password on the wp-admin folder, through your control panel's directory privacy feature, adds an extra step before WordPress is even reached. Exclude the admin-ajax.php file from this protection, because the public side of many sites uses it, and test your site after you turn it on.

Change the login address (with realistic expectations)

Plugins can move the login page from wp-login.php to a custom address. This removes most of the automated noise, because bots only knock on the default door. But it is security through obscurity: it hides the door and does not lock it. Use it as a noise reducer on top of 2FA and limits, and make sure you record the new address. Some plugins and themes expect the default login path, so test thoroughly.

Geo-blocking

If all your administrators are in one country, blocking login requests from other countries can cut a lot of attack traffic. Be aware that attackers use servers in many countries, and that travelling staff or VPN users could be blocked, so use it carefully.

Step 9: Reduce the Damage if Someone Gets In

  • Use least privilege. Give people the lowest role they need. Most users do not need Administrator.

  • Keep the number of administrators small, and review them regularly.

  • Disable the theme and plugin file editor in wp-config.php: define( 'DISALLOW_FILE_EDIT', true );

  • Switch off open registration unless you need it, and set the default role to the lowest one.

  • Keep WordPress, themes and plugins updated, and delete the ones you do not use. Vulnerable plugins are a common alternative route in.

  • End old sessions and remove old accounts when people leave.

  • Back up regularly and test restores. See backup and disaster recovery.

  • Serve everything over HTTPS so that logins and cookies are encrypted. See SSL certificates.

Step 10: Monitor Your Logs and Resource Usage

Hardening is not a one-off job. Watch for signs of attacks:

  • A sudden rise in CPU, entry processes or faults in your cPanel resource usage

  • Slow admin pages, or occasional 503 and 508 errors

  • Many requests to wp-login.php or xmlrpc.php in your access logs

  • Failed login notices, or lockout emails from your security plugin

  • New administrator accounts you did not create

  • Unexpected files, or changes to core files

If you have SSH access, you can summarise which addresses are making the most login attempts. Replace access.log with your real log file, and note that log formats and locations differ between servers (see our guide to SSH and command-line tools):

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

The command lists the ten addresses with the most login requests. Use it to spot attacks, and to feed your firewall or blocking rules. Hosting-level monitoring and uptime alerts also help you hear about trouble early.

A 10-Minute Hardening Checklist

If you do nothing else, do these:

  1. Replace weak passwords, and move to a password manager.

  2. Turn on two-factor authentication for every administrator and editor.

  3. Delete the "admin" user, and use a different display name.

  4. Install one reputable security plugin for login limits and bot checks, and do not stack several.

  5. Block XML-RPC if you do not use it.

  6. Remove unused plugins, themes and users, and update everything else.

  7. Turn off open registration, unless you need it.

  8. Take a backup, and check that you can restore it.

What to Do If You Think a Bot Got In

  • Change passwords for every administrator, and for the database and hosting accounts if you suspect more.

  • End all sessions, and turn on 2FA.

  • Check the users list for accounts you did not create, and remove them.

  • Scan the site for malware, and look for unfamiliar plugins, files and scheduled tasks.

  • Restore from a clean backup if the damage is serious, then update everything and close the hole that let them in.

  • Check your email and your hosting account for signs of misuse, such as spam being sent.

  • If personal data may have been exposed, consider your reporting duties. Our guide to the Data Protection Act explains them.

Common Mistakes to Avoid

  • Locking yourself out with IP rules or a login-address plugin you cannot reverse

  • Relying only on a hidden login address

  • Installing several overlapping security plugins that conflict

  • Using a CAPTCHA that fails for people who use screen readers, with no alternative

  • Blocking admin-ajax.php, which breaks forms and features on the public site

  • Blocking XML-RPC without checking whether a tool still needs it

  • Forgetting that stores and membership sites have other login forms to protect

  • Leaving old administrator accounts and unused plugins in place

  • Making changes on the live site with no backup and no way back

  • Ignoring the logs until the site is slow or hacked

Why Run WordPress on SteboHost

Login hardening works best on a platform that does part of the job for you:

  • A web application firewall, Imunify360 malware scanning and DDoS mitigation on every plan, which helps filter malicious requests before they reach WordPress. See website security.

  • 24/7 infrastructure monitoring of uptime, resources and security events, and a 99.9% uptime SLA.

  • Managed WordPress with automatic core and plugin updates, staging sites and LiteSpeed caching. See managed WordPress hosting.

  • Daily backups on shared hosting plans, with 7-day retention and one-click restore, so you can recover from the worst.

  • Automatic SSL certificates included with hosting plans. Current plan terms are on the pricing page.

  • Published resource limits on every plan page, so you can see how much headroom you have. See the plan limits.

  • Room to grow: VPS and cloud hosting gives you full root access for tools such as fail2ban and custom firewall rules.

  • Migration help on annual plans. Terms are shown on the pricing page and at checkout.

  • Local support on +254 703 610 464 during East Africa Time business hours, with 24/7 urgent monitoring, and billing in KES by M-Pesa, card or bank transfer.

Current plan and renewal prices are shown on the pricing page before you buy. You can also browse the knowledge base for more WordPress security guides.

Conclusion

Bots will keep knocking on your WordPress login page, but you can make sure that nothing opens. Use strong unique passwords, turn on two-factor authentication, limit attempts, add bot checks, close XML-RPC and username leaks, restrict access where you can and keep an eye on your logs. Layer these defences, keep a safe way back in and back up before you change anything. Together, they turn a constant threat into background noise.

Want a second pair of eyes on your WordPress security? Contact the team or call +254 703 610 464, and SteboHost will help you review your setup.

Frequently Asked Questions

Why are bots attacking my WordPress login page?

Because WordPress is so widely used, its login address is easy to guess and attackers can scan thousands of sites automatically. Bots try common passwords, leaked passwords from other breaches and usernames they can discover. Small and new sites are attacked too, because the attackers do not choose their targets by hand.

What is the best way to protect the WordPress login page?

There is no single best fix, but two-factor authentication with strong unique passwords gives the biggest improvement. Add login attempt limits, a bot check, a firewall and blocking of XML-RPC if you do not use it, and watch your logs.

Is changing the WordPress login URL enough?

No. It reduces automated noise because bots look for the default address, but anyone who finds the new address can still try to log in, and a hidden address does not stop credential stuffing. Treat it as a noise reducer, and keep two-factor authentication and attempt limits as your real protection.

Should I disable XML-RPC?

If you do not use it, yes. XML-RPC can accept many password guesses in one request and is rarely needed on modern sites. Some tools, such as certain remote publishing and plugin integrations, still depend on it, so check what you use before blocking it, and test afterwards.

Will login protection slow down my website?

Well-chosen protection has very little effect on visitors, and it often helps, because it stops bots from using your server's resources. Choose one reputable security plugin instead of several, and use a firewall at the hosting level where you can.

What should I do if I lock myself out?

Use SFTP or your hosting control panel to rename the security plugin's folder, or remove the .htaccess rule you added, which disables it so that you can log in. Then fix the setting, and keep a recovery method, such as backup codes for two-factor authentication, written down safely.

Do I need a security plugin if my host has a firewall?

A host's firewall works at the server level and blocks a lot of bad traffic, while a plugin works inside WordPress and can add two-factor authentication, login limits and user-level controls. They complement each other. Use both, but keep to one well-maintained security plugin.

#WordPress#Security#Login Security#Brute Force#Bots#2FA#XML-RPC#Hardening
M

Written by Mercy Chepkemoi

SteboHost engineering and operations team. We write practical guides on hosting, domains, email and security for African businesses — based on what we see in the field, not marketing copy.

Ready to get started?

Browse our hosting plans or contact our team for help choosing the right one.