How to Block Certain Countries on WordPress

How to Block Certain Countries on WordPress

Do you want to secure your content from other countries? Or you don’t want some particular IP addresses to sneak into your content?

If you running a website, then by default it is accessible to everyone. For some reasons, you don’t wanna share your content to other nations or your website is simply not relevant to people in other countries.

However, you’d want to allow visitors from all over the world to access your website. But there are situations when there is a need to block visitors from some countries.

Method 1 – Deny with .htaccess (not a great plan)

The first step is to determine which IP addresses come from which countries. There are some sites out there to assist us in this. For example, here is a complete list of Romanian IP addresses. If you want, you can use the same site to get the ranges of other countries as well. You can see that it contains almost 300 entries. And these are ranges! What’s more, they keep changing so this is not a static list.

However, if you want to go ahead and deny these ranges via .htaccess, you can use a tool like this to generate the .htaccess rules for a specific country. But if you use these rules “as is” without any modification, you’re going to kill your server since it has to perform a lookup for each and every hit. Moreover, this will also generate a 403 forbidden error page. And while the raw size of an individual error page is small, your site may still be consuming unacceptable amount of bandwidth in the case of a large-scale DDoS attack.

All of this leads us to the second – and more preferable – technique of blocking countries.

Method 2 – Using CloudFlare

CloudFlare is one of the most well-known reverse proxy services and its basic package is free to use for anyone. If you haven’t already signed up for the service, you should do so now. If you’re using some other reverse proxy protection for your website, they might have their own tools for blocking specific countries. But if you’re already using CloudFlare, then setting up country based blocking is a cinch. Simply go to the “Firewall” section after you’ve logged in as shown here:

How to Block Certain Countries on WordPress

Now scroll down to “Firewall Rules” and in the input box, type in the name of the country you wish to restrict. In this case, I’ve selected “Romania” and opted for the “Create Firewall Rule” restriction. This way, anyone accessing my site from Romania will be presented with a simple challenge to ascertain whether they’re a person or a robot.

How to Block Certain Countries on WordPress

How to Block Certain Countries on WordPress

Once you save your changes, you can test out the protection by accessing your site via a proxy server from that specific country. You can see below that when I type in the URL of my site from Romania, I get a JavaScript challenge to prove that I’m not a bot. Once I pass that, I can access the site as usual.

The advantage of this method is that it doesn’t place any processing overload on your site. All of that heavy lifting is taken care of by your reverse proxy – in this case CloudFlare. They perform their own internal optimized checks in the background for determining the country. The only problem is that you can’t categorically block all access to a nation by default. Instead, you can only stipulate a challenge.

Method 3 – WordPress plugins to block countries

Here, are the 5+ best WordPress plugins to block countries and to save your data.

1. iQ Block Country – WordPress Plugins To Block Countries

iQ block plugin uses the GeoLite database from Maxmind. A Maxmind is a company which detects online fraud and provides location data for IP addresses.

This plugin has up to 30,000+ active installations. Moreover, iQ block plugin can be translated into 2 languages: Dutch & English (US).

Price –

With a rating of 4 stars out of 5, this plugin is available free of costs.

Features –

  • With this plugin, you can block countries or some selected IP addresses. Or you can also allow only some IP addresses to sneak into your content, not the whole country.
  • It works with Maxmind’s database, which helps you to block the unwanted users.
  • Many cache plugins are not compatible with this plugin but, comet cache, WP super cache are compatible with this plugin.

2. WP GEO Website Protection – WordPress Plugins To Block Countries

Using this plugin, you can prevent huge attacks on the administrative panel of your site.

Also, you can easily filter front-end visitors and visitors who want to login to WordPress backend.

Moreover, you can block the whole country and allow only a few IP addresses to sneak into your content.

Price –

This amazing plugin is available free of cost and has almost more than 400+ active installations.

Features –

  • You can stop visitors from different parts of countries.
  • Also, you can ban visitors who try to sneak into your backend login page.
  • Using this plugin, you can see the graphical representation of all the blocked countries.
  • This plugin helps you in banning the IP addresses which are characterized by hack attempts, spamming and etc.

3. IP2 Location Country Blocker – WordPress Plugins To Block Countries

IP2Location is a Geo IP solution which identifies your visitor’s geographical location without invading user’s privacy.

Using this plugin you can save your backend and frontend that is admin & block area from the proxy servers or countries. In fact, IP2 Location Country Blocker has many ways to save your data from filching.

Moreover, this plugin supports both BIN data and web service. You can use IP2Location BIN data, which can be easily downloaded. And later on, you can update the BIN data via the plugin settings page.

Price –

The pricing of this plugin depends on the product and the requirement. You can visit their sales page for more details.

Features –

  • This plugin allows you to customize your own 403 page.
  • You will immediately receive an email notification if someone tries to access your admin area.
  • Also, with this plugin, you can see the statistical report of all the traffics blocked by you.
  • In addition, the IP2 plugin supports IPv4 and IPv6, which help in restricting the nondescript proxies.

4. IP Geo Block

IP geo block is another popular freemium blocking country plugin. It receives over 40k downloads along with great overall reviews (4.5).

The key feature of this plugin is that it will not only block country’s IPs but also protects from an attack to the back-end of our site by blocking requests from undesired countries and also with the original feature ”zero-day Exploit Prevention”(WP-ZEP). It also prevents unwanted entries from the login form, comments, and XML-PRC. That’s why this plugin is listed on this list.

IP Geo block uses multiple sources of IP Geolocation databases such as IP2locations, Maxmind. It cooperates with full spec security plugin, easy rescue, and self-blocking prevention, etc.

5. Wordfence Security – Firewall & Malware Scan

Almost every WordPress users know about Wordfence, it’s one of the most popular WordPress security plugins in the market.

WordFence comes with both Free and Paid version. The paid version has extra features including IP blocking and that’s the main reason I put this plugin in last. You have to pay for the feature you need.

But I think it’s worth to invest money on this plugin if you are getting tons of attacks daily because with this plugin you’re not only securing content from other country but also it has complete security features. It’s for firewall, malware scan, blocking IP’s, live traffic monitoring, login security and more.


Now there are tons of plugins in the market who does the same job or better than this. The only reason I put this these plugin on this list because I already used and I must say these plugins might be a better choice when it comes to blocking country’s IPs.

If you know any better plugin than these, let us know in the comment section. We’ll surely put your choice plugin on this list.


About the author

Amy Gorrell

Amy Gorrell

Amy is a content writer at ERROR HAT. She has years of experience in business and marketing. She also loves technology-related topics. Apart from writing, love to read and watch movies.

Add Comment

Click here to post a comment