How to block an IP address or a country from your website (cPanel IP Blocker)
Spam bots, people trying to guess your passwords or a scraper copying your content often come from the same IP addresses. This guide shows you how to block an IP address with the cPanel IP Blocker tool, how to block a whole range, and what your options are when you want to block a country.
What IP Blocker does (and does not do)
- It stops the blocked addresses from opening your website. They get a 403 Forbidden page.
- It works by adding deny rules to the
.htaccessfile in your account (see how to use the .htaccess file). - It does not block email, FTP or other services. It only affects web traffic.
How to block an IP address
- Log in to cPanel (how to log in to cPanel).
- In the Security section, open IP Blocker.
- In the IP Address or Domain box, type the address you want to block.
- Click Add. The address now appears under Currently-Blocked IP Addresses.
Formats you can use
| Format | Example | Blocks |
|---|---|---|
| Single IP | 203.0.113.45 | One address |
| Range | 203.0.113.10-203.0.113.50 | Every address in the range |
| Short range | 203.0.113.10-50 | The same range, written shorter |
| CIDR | 203.0.113.0/24 | 203.0.113.0 to 203.0.113.255 |
| Partial | 203.0.113. | Every address that starts with 203.0.113 |
IPv6 addresses are also accepted. If you type a domain name, cPanel looks up its IP address at that moment and blocks the IP, not the name.
How to find the IP addresses to block
- In cPanel, open Raw Access or Visitors (in the Metrics section) to see which IPs are requesting your pages.
- In WordPress, a security plugin such as Wordfence or Limit Login Attempts shows the IPs of failed login attempts. See how to secure your WordPress website.
How to unblock an IP
- Open IP Blocker again.
- Under Currently-Blocked IP Addresses, click Delete next to the address and confirm.
How to block a country
IP Blocker works with IP addresses, not countries. A country has thousands of ranges that change over time, so pasting them into .htaccess by hand makes the file huge and slows the site. Better options:
- Cloudflare (recommended): if your domain uses Cloudflare, create a WAF custom rule with the field Country, choose the country and set the action to Block or Managed Challenge. This is available on the free plan and stops the traffic before it reaches your hosting.
- Ask EgWeb support: for persistent attacks, open a ticket. We can review the traffic and advise on blocking at server level.
Think carefully before you block a whole country. You may also block search engine crawlers, payment gateways or customers who travel.
Common problems
- The blocked visitor can still open the site: they may be using a different IP, a VPN or Cloudflare. If your site is behind Cloudflare, block them in Cloudflare instead.
- The whole site shows 403 after a change: you may have blocked a range that includes your own IP. Delete the entry from another network (for example mobile data).
- Your own IP is blocked from cPanel or email: that is a server firewall block, not IP Blocker. Contact support with your IP address.
Frequently asked questions
Is there a limit to how many IPs I can block?
There is no fixed number, but a very long list in .htaccess slows every request. For large lists use Cloudflare.
Will blocking an IP stop a DDoS attack?
No. Large attacks come from thousands of addresses and must be filtered before they reach the server, for example by Cloudflare. Contact us if your site is under attack.