TL;DR
You can block a website’s HTTPS version using your firewall or hosts file. This guide shows you how to do both.
Blocking HTTPS with Your Firewall
- Identify the Website’s IP Address: First, find out the IP address of the website you want to block. You can use a command-line tool like
pingor an online lookup service.ping example.com - Access Your Firewall Settings: The way you do this depends on your firewall software (e.g., Windows Defender Firewall, pfSense, iptables). Look for settings related to ‘Outbound Rules’ or ‘Block Lists’.
- Create a New Block Rule: Add a new rule that blocks traffic to the website’s IP address on port 443 (the standard HTTPS port).
- Rule Name: Give your rule a descriptive name, like “Block Example.com HTTPS”.
- Direction: Set the direction to ‘Outbound’ (to prevent your computer from connecting).
- Protocol: Select ‘TCP’.
- Local Port: Usually set to ‘Any’.
- Remote Port: Set this to 443.
- Remote IP Address: Enter the IP address you found in step 1.
- Action: Set the action to ‘Block’ or ‘Deny’.
- Enable the Rule: Make sure the rule is enabled and saved.
- Test the Block: Try accessing the website using
https://example.comin your web browser. It should be blocked.
Blocking HTTPS with Your Hosts File
This method redirects requests for the website to a non-routable IP address (127.0.0.1, which is your own computer).
- Locate Your Hosts File: The location depends on your operating system:
- Windows:
C:WindowsSystem32driversetchosts - macOS/Linux:
/etc/hosts
- Windows:
- Open the Hosts File as an Administrator: You’ll need administrator privileges to edit this file. On Windows, right-click Notepad and select ‘Run as administrator’. On macOS/Linux, use a command like
sudo nano /etc/hosts. - Add a New Entry: Add a line at the end of the file in the following format:
127.0.0.1 example.comIf you want to block both
example.comandwww.example.com, add two lines:127.0.0.1 example.com 127.0.0.1 www.example.com - Save the Hosts File: Save the changes to the file.
- Flush Your DNS Cache (Optional): This forces your computer to read the updated hosts file immediately.
- Windows: Open Command Prompt as administrator and run
ipconfig /flushdns - macOS: Open Terminal and run
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder - Linux: The command varies depending on your distribution (e.g.,
sudo systemd-resolve --flush-caches)
- Windows: Open Command Prompt as administrator and run
- Test the Block: Try accessing the website using both
http://example.comandhttps://example.comin your web browser. It should redirect to your own computer or show an error.
Important Note: Blocking a website with your hosts file only affects your computer. The firewall method can block access for all devices on your network (depending on how it’s configured).