Block an IP address on your website (cPanel)
IP Blocker denies access to your site to an IP address, a range of addresses or a domain name, for example to keep out a bot or an abusive visitor. cPanel's tool does not block a whole country: the "Block a country" section explains the alternatives.
Before you start
- Have your cPanel credentials ready: see Log in to cPanel.
- Note the IP address to block, which you will find in your site's logs or in the alert email.
- Do not block your own address: you would lose access to the site. If you do not know your address, do not go on before you find it out.
- IP Blocker only appears if your hosting provider has enabled it for your account.
- This tool blocks access to your site. It does not block other services, such as webmail. A server-level block goes through the hosting provider (WHM, Host Access Control): contact support.
- The labels below come from cPanel's official documentation, in English; the French version of your cPanel may translate some of them.
Steps
Block an address
- In cPanel, open Security › IP Blocker.
- In IP Address or Domain, enter the address or range. The accepted formats are:
- a single address:
10.5.3.33; - a range:
10.5.3.3-10.5.3.40; - a shortened range:
10.5.3.3-40; - CIDR format:
10.5.3.3/32; - an incomplete address:
10.(which blocks every address starting with 10).
- a single address:
- Click Add.
cPanel splits ranges into CIDR-format subnets and adds them to the site's .htaccess file. If you type addresses directly into .htaccess, use CIDR format only.
See the blocked addresses
The Currently-Blocked IP Addresses table lists each block: Server Setting (the range in CIDR format), Beginning IP (start of the range) and Ending IP (end of the range).
Unblock an address
- In the table, click Delete in the Actions column of the row.
- Click Remove IP.
Block a country
IP Blocker has no country-based blocking: it only knows addresses, ranges and domain names. Blocking all of a country's ranges by hand is not realistic, because the lists are long and change. Depending on your situation:
- if your domain goes through a service such as Cloudflare, a firewall rule can block requests by their country of origin (Cloudflare's documentation shows a rule on the
ip.src.countryfield with the Block action); - otherwise, ask support for advice.
Expected result
The block appears in Currently-Blocked IP Addresses. A visitor who uses that address can no longer reach your site; other visitors are not affected.
If something goes wrong
- You blocked your own address: if you no longer have access to the site, delete the rule from another connection (for example your phone's mobile network) with Delete, then Remove IP. You can also remove it from the
.htaccessfile with the File Manager. - The visitor comes back with another address: blocking an address does not stop a visitor who changes address or uses a relay.
- A service other than the site is still reachable: that is normal, IP Blocker only blocks the site (not webmail, for example).
- Legitimate visitors are blocked: check the range you entered, especially if you used an incomplete address such as
10..
FAQ
How do I find the IP address of a visitor to block?
In your site's access logs (cPanel offers the Metrics › Raw Access screen) or in your application's alerts.
Can I block a domain name?
Yes: the field accepts an IP address or a fully qualified domain name (FQDN).
Can I block a country with cPanel?
Not with IP Blocker. See the "Block a country" section above for alternatives.
What happens if I block a range that is too wide?
All visitors in that range lose access to the site. Delete the rule with Delete, then Remove IP, and start again with a more precise range.
What can I do against unwanted emails?
IP Blocker does not block mail. For senders, see Block a sender and filter your emails.
Related articles
- Password protect a folder on your website
- Use cPanel's File Manager
- Log in to cPanel: address, credentials and a tour of the interface
A site to secure? Discover our security solutions.