Docs

How geo-blocking works

5 min readUpdated November 19, 2026

Geo-blocking lets you stop the login form from loading for visitors in countries you choose. It’s useful if your users all live in a few countries and most of the bots hitting your login page come from somewhere else.

A settings screen for geo-based login control featuring toggle switches and dropdown menus. It includes options to enable geo filtering, select a fallback method, choose an IP lookup API, and configure an API key and cache duration.

What geo-blocking does#

When a visitor from a blocked country opens your login page, Shield doesn’t show the login form. It shows an “Access restricted” screen with your message instead. Attackers in that country can’t submit a password to guess, so the attack never starts.

It covers the login only. Your public pages, posts and shop stay open to everyone. Visitors from blocked countries can still read your site. They just can’t sign in.

The block also applies to Shield’s other sign-in routes: WooCommerce My Account login, magic links, passkeys, the Bricks Builder login form, and Shield’s REST sign-in endpoints. A blocked visitor can’t go around the login page by using one of those.

How Shield finds a visitor’s country#

Shield checks two sources, in this order.

1. CDN country headers. If your site is behind a CDN or proxy, the CDN usually adds a header to each request saying which country it came from. Shield reads these headers in this order and uses the first valid two-letter country code it finds:

  1. Cloudflare (CF-IPCountry)
  2. Bunny.net (CDN-Country)
  3. AWS CloudFront (CloudFront-Viewer-Country)
  4. Vercel (X-Vercel-IP-Country)
  5. Fastly and Akamai (X-Country-Code)
  6. Generic reverse proxy (X-Geo-Country)

This is the fastest option. It adds no delay and uses no outside service. The next topic after this one, “Supported CDN country headers,” covers each header in detail.

2. An IP lookup service. If no header gives a country, Shield asks an IP lookup service. You choose which one in the IP lookup API setting:

  • freeipapi.com: free, no key needed, limited to 60 requests per minute.
  • ipinfo.io Lite: free, but you need to create an account and paste in a token. No request limit.
  • None: CDN headers only. Shield never contacts a lookup service.

Shield waits up to 3 seconds for the service to answer. It then remembers the result for that IP, so repeat visits don’t trigger another lookup. You choose how long it remembers, from 1 to 168 hours. The default is 24.

A settings interface displays a list of 101 blocked countries, each represented by its flag icon and a two-letter country code. Below header buttons for various regions, a dense grid of rectangular buttons lists nations alphabetically, from Afghanistan to Zimbabwe.

What happens when the country can’t be found#

Sometimes Shield gets no country. There may be no header, the lookup service may be down, or it may not recognise the IP. The Fallback setting decides what Shield does:

  • Allow (default): show the login form. Local development sites and servers that can’t reach a lookup service keep working.
  • Block: hide the login form. This is stricter, but a lookup outage will lock everyone out of login until it recovers.

If you use Block, always keep a whitelisted IP or NAHNLS_BYPASS_IP set so you can still sign in. See “I locked myself out” in the Troubleshooting section.

Who is never geo-blocked#

  • IPs on your whitelist (Lockout tab).
  • IPs listed in the NAHNLS_BYPASS_IP constant in wp-config.php.

These skip the country check completely. “Block countries and whitelist IPs,” the next topic, shows how to set this up.

Turning it on#

  1. Go to Settings → Login Shield and open the Geo tab.
  2. Turn on Block login form by country.
  3. Under Country blocklist, choose Use a custom list at login, then pick the countries to block.
  4. Choose your detection source. If you use a CDN, leave Trust CDN geo headers on. If not, pick an IP lookup API.
  5. Click Save geo settings.

Geo-blocking does nothing until you turn on both the switch and a country list. If you turn on the switch but leave the list on No country filtering at login, nobody is blocked.

What gets logged#

Blocked attempts are recorded in the event log as Geo block, at most once per IP per minute. With the early-block file installed, the IP is then refused for 15 minutes without further log entries. The top row of the General tab shows a Geo blocked today count. If you’ve turned on login alerts for geo blocks, Shield also sends the notification. See “The event log” and “Login notifications and the weekly digest” in the Monitoring section.

Limits to know about#

  • It’s not a firewall. Geo-blocking relies on the country of the connecting IP. Someone using a VPN or proxy in an allowed country looks like they’re in that country. Use it as one layer next to lockouts and 2FA, not instead of them.
  • Without a CDN, the lookup is only as good as the service. IP-to-country data is usually accurate but never perfect.
  • Headers can only be trusted if they come from your CDN. If your site isn’t behind a CDN, someone could send a fake country header. If you don’t use a CDN, turn off Trust CDN geo headers so Shield ignores them.
  • IP lookups send visitor IPs to a third party. With freeipapi or ipinfo, each new IP that reaches your login page is sent to that service. This matters for your privacy policy. See “External services Shield can contact” in the Privacy and Data section.

Geo tab vs. OOPSpam’s country list#

If you use OOPSpam as your CAPTCHA provider, it has its own country setting. That one is judged by OOPSpam when a login is submitted. The Geo tab blocks earlier, before the form is shown. Use the Geo tab if you want visitors to never see the form.

Was this helpful?

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only