BetterShield
Appearance
Login protectionLockoutsSign-in

Limit login attempts in WordPress without locking yourself out

· · 12 min read

Updated by Nazmul Hasan Rupok on

Out of the box, WordPress lets anyone keep trying passwords at your sign-in form for as long as they like, and a script can keep going far longer than any person would. The usual answer is to limit login attempts in WordPress: after a few wrong passwords, stop listening for a while.

Done carelessly, that limit can lock the real owner out or, behind a proxy, put every visitor under one lockout. BetterShield pauses the connection that keeps failing, never the account, acts only on addresses it can verify, and leaves you a way back in. It starts at activation, so on most sites the job is checking it, not building it.

Quick summary

  • By default, 5 wrong passwords in 15 minutes pause sign-in from that connection for 15 minutes, doubling for each repeat within a day, up to a day.
  • The account is never locked. BetterShield automatically emails a lockout notice only when the account has used that network within the last 30 days, or its correct password was used. On a new network, choose Email Me an Unlock Link on the sign-in screen and enter your username or email address. A link is sent only when that lockout qualifies, to the address already saved on the account.
  • Only a verified address is ever locked out. Behind a proxy, name it under Trusted proxies. Behind Cloudflare, lockouts already run; press Yes, this site is behind Cloudflare so each one follows the visitor.
  • Comments, password resets and sign-ups have their own limits, counted apart from sign-in.
  • Keep recovery material off the site. Add an address to Always allowed only when you deliberately trust every relevant request from it.

Why repeated wrong passwords are a problem

Guessing passwords is cheap: without a limit, nothing makes the hundredth guess slower than the first. A strong password is still what keeps people out; a limit adds to it by making each round of guesses wait. That is the core of WordPress brute force protection.

You can lock the account after a few failures, or pause the connection the failures came from. Locking the account sounds stricter, but it lets anyone who knows your username keep you out of your own site. BetterShield pauses the connection, so the account can still sign in from another permitted connection. People sharing the counted connection may share its pause.

What a sensible limit looks like

  • Room for honest typos. People mistype, and password managers fill in old passwords. Failures allowed cannot go below 3, because below three, a mistyped password becomes a lockout.
  • A short window and a short pause. The default counts 5 failures within 15 minutes, then pauses for 15 minutes, so a first pause lasts fifteen minutes; repeat pauses can be longer.
  • Longer pauses for whoever keeps coming back. With the defaults, a repeat within a day waits 30 minutes, then an hour, then two, up to a full day.
  • A way out for the real owner. Every pause ends on its own, and the owner can end it sooner from an email.
Understand the counter

A pause follows a resolved connection

The limit depends on more than the number of wrong passwords.

  1. Resolve the visitor

    Trust the correct proxy.

  2. Count failures

    Use a defined time window.

  3. Pause and recover

    The connection waits.

Resolve the visitor

What this means
The site must distinguish the visitor from the proxy and ignore untrusted forwarding headers. Shared networks can still contain many people.
Your next check
Compare two independent networks in How this site sees you.

Count failures

What this means
With defaults, five failures within fifteen minutes trigger a pause. Low thresholds can also affect legitimate users sharing a connection.
Your next check
Use a test account and a spare network on staging, not a live customer’s credentials.

Pause and recover

What this means
The account itself is not locked, but every person behind the same counted connection may feel the pause. Repeat pauses can last longer.
Your next check
Confirm the release path and keep a second administrator session available.
An IP-based limit slows repeated attempts from a connection. Distributed attempts and a correctly stolen password need other protections.

How to limit login attempts in WordPress with BetterShield

  1. Open BetterShield › Protection › Login & Access.
  2. Look at Connections in the summary at the top. Verified means lockouts can run. Not verified means they are paused; see the proxy section below.
  3. Under Sign-in protection, check that Sign-in attempt limits is on.
  4. Adjust Failures allowed (3 to 100), Counted within (minutes) and Pause lasts (minutes) (both 1 to 1440) if you need to.
  5. Press Save in the bar that appears, or Discard to drop your edits.

What a WordPress login lockout looks like here

  • The sign-in form tells that connection there have been too many failed sign-ins and asks it to wait.
  • The pause appears under Lockouts, running ones first. Each row names the network (such as 203.0.113.0/24), but the pause covers only the one IPv4 address that failed, or one IPv6 /64. Release now ends one early.
  • An automatic lockout notice is sent only for a network the account used within the last 30 days, or when its correct password was used. Otherwise, choose Email Me an Unlock Link on the sign-in screen. An eligible link leads to Clear the lockout. A pause released either way starts the doubling over.
  • Wrong two-factor codes and wrong application passwords count toward the limit too.

The hidden bot check

Refuse obviously automated submissions is on by default. It adds an invisible field and a clock to the sign-in, registration, comment and store account forms, and refuses a script that fills in every field or submits within two seconds. People see nothing. By the screen’s own account, it cuts bot noise rather than stopping a determined person. A WordPress login CAPTCHA alternative goes through what it refuses and what it leaves alone.

A small puzzle after failed sign-ins

Ask for a sign-in puzzle after wrong passwords is off by default. After two wrong passwords from one connection, the next attempt pauses for a moment while the browser solves a small puzzle, a little harder after each further failure. It needs JavaScript, and HTTPS or localhost. An unsolved puzzle never counts toward a lockout, the puzzle lifts once the counting window passes, and addresses on Always allowed never see it.

A notice for sign-ins from a new network

Tell an account holder about a sign-in from a new network is off by default. When on, the person whose account it is (not your alert list) is emailed the first time the account signs in from a new network, at most once a day. Nothing is blocked.

Proxies and Cloudflare: telling visitors apart

A limit only works if the site can tell who is signing in. Behind a reverse proxy, a load balancer or a CDN, every request can arrive from the proxy’s address. Counting that address would put every visitor under one lockout, you included; believing any forwarding header would let anyone choose the address they appear to come from.

So only a verified address is ever locked out; anything else is recorded, never locked. An unnamed proxy turns lockouts off rather than locking everyone behind it, and Findings shows “Failed sign-ins are not being counted, so password guessing is not stopped” until it is fixed.

How this site sees you, under Who is at the door, reads your own request and stores nothing. It says either that automatic lockouts are active or why they are not running yet. Press Check again after any change.

  • Cloudflare is recognized by its published address ranges and needs no entry under Trusted proxies. If the screen asks, press Yes, this site is behind Cloudflare so each lockout follows the visitor; until then, a lockout counts the Cloudflare address and the visitor’s together. Turn that off withdraws that trust.
  • Another proxy goes under Trusted proxies, in Addresses or ranges, separated by commas. The visitor address it forwards in its X-Forwarded-For header is then believed. If it is named and lockouts still are not running, set it to send that header.
  • A server that runs Fail2Ban can be told about each pause. On the Server firewall card, Send lockouts to the server’s firewall (off by default) writes one line to the server’s auth log for each pause, naming the network (IPv4 /24, IPv6 /64), never an address or a username. A sample filter and jail come with the plugin, and a network that holds an address on Always allowed writes nothing. See Server firewall.

If you want WordPress login limits without managing a server jail, see BetterShield as a Fail2Ban alternative for WordPress. The guide compares setup and recovery, explains when to keep both, and gives you a test to run before switching.

Allow and block lists

Both lists are under Allowed and refused.

  • Always allowed holds addresses that are never locked out, never held by form limits and never given the puzzle. Addresses only, because a user agent is a claim anyone can make. A fixed office address may be suitable, but its exemption covers requests from that address, not only your own account.
  • Never allowed to sign in refuses sign-in, never browsing. An entry is an IP address or CIDR range, a username or a user-agent fragment of four characters or more, with an optional Note.

A username on its own is refused from anywhere, even an allowed address, with the answer a wrong password gets. While Sign-in attempt limits is on, a verified connection that tries one is also paused on that first try, unless its address is on Always allowed. A range applies only to verified connections, and your own username cannot be added.

Public forms have their own limits

Under Request protection, comments, password reset requests and sign-ups are counted separately from sign-ins, so a busy form never locks you out of your dashboard. Each has Closes at this many (3 to 100), Counted within (minutes) and Closed for (minutes).

OptionOnce the limit is reachedDefault
Hold a burst of comments for moderationThat comment and further ones wait in moderation. Nothing is discarded; moderators are never held.On: 10 in 10 minutes, closed 30 minutes
Slow repeated password reset requestsThat request and further ones get the answer a successful one gets, so no account is revealed.On: 8 in 15 minutes, closed 15 minutes
Slow repeated sign-upsThat sign-up and further ones are refused until later. Only where registration is open.On: 8 in 1 hour, closed 1 hour

Before you save, new numbers are replayed against the last two days of attempts, so you see what they would have held or refused. Limit comment spam and password resets in WordPress covers each form in full.

How to avoid locking yourself out

  1. Keep your way back in off the site. The recovery link emailed at activation works once, lasts 90 days, and turns on safe mode for an hour, which pauses everything on Login & Access. On Protection › Recovery, Issue recovery codes gives you eight printed codes for the day email fails.
  2. Review any exemptions. A fixed address is not automatically trustworthy. Add only controlled addresses whose bypass you intend, and record why.
  3. Check a range before you block it. A blocked range that includes your own network refuses you too.

If it happens anyway, Locked out of WordPress? covers every way back in.

Test the counter without interrupting customers

Use a staging site, a disposable account and two connections you control, such as an office network and a mobile connection. Keep another working administrator session available. Do not deliberately trigger a lockout from a busy shared customer or office network on production.

  1. Check How this site sees you from both networks. Confirm that the proxy configuration produces the expected separation.
  2. From the test network, submit enough wrong passwords for the configured threshold. Note the time and the pause displayed.
  3. Use the other network to sign in correctly to the same test account. This checks that the account itself was not disabled.
  4. Release the test lockout and complete a correct sign-in from the first network.
  5. Confirm the expected activity record and, where applicable, receipt of the unlock email. Sending an email and delivering it are different outcomes.

Worked example (fictional): a coworking office shares one public IPv4 address. One person repeatedly uses an old saved password and triggers a pause. Other users behind that same address can be affected even though their accounts remain valid. Correcting the saved password and releasing the specific pause is more useful than lowering protection for every visitor.

Avoid adding a broad shared network to Always allowed simply to make a test pass. The exemption also benefits unwanted requests from that network. Use it only for a deliberately trusted, controlled address and review it when the office or hosting arrangement changes.

Common mistakes

  • Assuming lockouts run behind a proxy. If Connections reads Not verified, name the proxy under Trusted proxies first.
  • Two plugins limiting sign-in. Quick Setup asks which plugin keeps Sign-in attempt limits, because two limits lock a person out twice. If both end up limiting anyway, Findings shows “Two plugins limit sign-in attempts”. If you later remove the other one, Findings shows “Nothing is limiting sign-in attempts” until you switch Sign-in attempt limits back on.
  • Caching the sign-in page. A cached copy can show one visitor’s lockout answer to the next. If Findings shows “Your sign-in page is being cached”, exclude the sign-in address from caching.

Frequently asked questions

How many login attempts should WordPress allow?

BetterShield’s default is 5 wrong passwords within 15 minutes, then a 15-minute pause that doubles for a connection paused again within a day. You can allow 3 to 100; below three, a mistyped password becomes a lockout.

I see too many failed login attempts. What now?

Your connection has reached the limit. Wait for the pause to end (15 minutes by default), or open the unlock link sent to your account’s email address and press Clear the lockout. Another administrator can also press Release now.

Does login protection work behind Cloudflare?

Yes. Cloudflare is recognized by its published ranges and needs no Trusted proxies entry. When How this site sees you asks, press Yes, this site is behind Cloudflare so each lockout follows the visitor. Until you do, a lockout counts the Cloudflare address and the visitor’s together.

Is BetterShield’s brute-force protection free?

Yes. Everything in this guide is in the free BetterShield plugin on WordPress.org, with no account needed.

Conclusion

To limit login attempts in WordPress well, pause the connection rather than the account, make sure the site can tell visitors apart, and keep your own way back in. BetterShield starts with sensible numbers, so on most sites the one thing to confirm is that Connections reads Verified.

Then save your recovery link somewhere off the site. The full reference is the Login & Access guide.

Close the open doors today

Install the free plugin. The first audit runs when you activate it, and all but one of the fixes wait for your choice.

Requires WordPress 6.7 or newer and PHP 8.0 or newer.

Get BetterShield