Block an IP address or a country from your website
Updated 27 Nov 2026
If one address keeps attacking your contact form or login page, or you see a flood of visits from a place you don't serve, you can block it. Blocked visitors see a 403 Forbidden page instead of your site.
Find the address to block
- Open Services, choose your hosting and press Login to cPanel.
- Under Metrics, open Visitors and choose your domain. The IP column shows who visited each page.
- Look for one address making many requests to the same page, such as
wp-login.phporxmlrpc.php.
Before blocking, check it isn't your own address, your office or a service you use. Search "what is my IP" on your phone and computer to see yours.
Block an IP address with IP Blocker
- In cPanel, under Security, open IP Blocker.
- In IP Address or Domain, enter what to block. You can use:
| Format | Example |
|---|---|
| One address | 203.0.113.45 |
| A range | 203.0.113.1-203.0.113.50 |
| A network (CIDR) | 203.0.113.0/24 |
| Everything starting with | 203.0.113. |
- Press Add.
The block works straight away for every domain in your hosting. To remove it, press Delete next to the address under Currently-Blocked IP Addresses.
Block addresses with .htaccess
IP Blocker writes its rules into .htaccess for you. You can also add them yourself, for example to block only one folder.
- In File Manager, press Settings, tick Show Hidden Files (dotfiles) and press Save.
- Edit
.htaccessin the folder you want to protect and add:
<RequireAll>
Require all granted
Require not ip 203.0.113.45
Require not ip 198.51.100.0/24
</RequireAll>
- Press Save Changes and test your site.
Block a whole country
cPanel has no simple country switch by itself, because one country can use thousands of address ranges. You have two good options:
- If you see a country blocking tool in cPanel, for example under Imunify360 or another security icon on your server, use it there.
- Otherwise, use Cloudflare (the free plan works). Point your domain's nameservers to Cloudflare, then go to Security › WAF › Custom rules, create a rule where Country equals the country, and choose Block. Cloudflare stops those visitors before they reach your hosting.
Think carefully before blocking countries. Your customers or church members may travel, and some phone networks route traffic through other countries. Blocking can cut off real people. Often it is better to protect only your login page.
Protect WordPress logins instead
Most attacks on small sites are robots guessing WordPress passwords. Blocking addresses one by one never ends. These work better:
- Use a strong admin password and two-step login with a security plugin.
- Don't use
adminas a username. - Turn off XML-RPC if you don't use the WordPress phone app or Jetpack. Many security plugins have a switch for this.
If your site is under heavy attack, open a ticket. We can block attackers at the server firewall, which is faster than .htaccess.
Stuck? Open a ticket and choose Technical. Our team can do it for you. Not hosting with us yet? See our cPanel hosting plans.