Blog | G5 Cyber Security

Block HTTPS Website

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

  1. 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 ping or an online lookup service.
    ping example.com
  2. 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’.
  3. 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’.
  4. Enable the Rule: Make sure the rule is enabled and saved.
  5. Test the Block: Try accessing the website using https://example.com in 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).

  1. Locate Your Hosts File: The location depends on your operating system:
    • Windows: C:WindowsSystem32driversetchosts
    • macOS/Linux: /etc/hosts
  2. 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.
  3. Add a New Entry: Add a line at the end of the file in the following format:
    127.0.0.1 example.com

    If you want to block both example.com and www.example.com, add two lines:

    127.0.0.1 example.com
    127.0.0.1 www.example.com
  4. Save the Hosts File: Save the changes to the file.
  5. 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)
  6. Test the Block: Try accessing the website using both http://example.com and https://example.com in 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).

Exit mobile version