How to use the hosts file to Block Adult Websites


Quickly block thousands of websites for free using the computers hosts file. This is one of the easiest and free ways to block porn on PC.

Blocking websites using the hosts file is a fairly straightforward process that involves adding a line to the file containing an IP address like or and then the website you want to block (separated by space). The process is the same on Windows and Mac.

For example, you can block websites like Youtube and Facebook by adding the following lines to your hosts file:

# Blocked Sites #

# End Blocked Sites #

Note that you should include a line blocking the website with the www prefix and version without www.

Using lists to block thousands of websites

Social media websites like Youtube, Facebook, and Reddit use other web addresses to function properly. If you want to thoroughly block those websites, including any websites that "mirror" them using API services, you should use blocklists.

Additionally, you can block entire categories of websites, such as VPNs & Proxies, services that invade your privacy, and pornographic content.

If you want to block categories like Adult Content on MacBook or windows computers, you can copy/paste the entries from these sources into your hosts file:

Members Only Blocklist Generator

Access advanced DNS Filtering, blocking tools, and step-by-step tutorials for creating Porn Blocking Systems.

Force Safesearch

You can use the hosts file to force Google Safesearch or Youtube restricted mode so that the user can't override the setting.

Force Google Safesearch

The host file can be used to force safesearch on some of the well known search engines.

Adding the following lines will trigger the safesearch mode on Google.

## Google Safe Search ##

Force Youtube Strict Mode

Force strict mode on Youtube by adding the following entries to your host file:

## Youtube Safe Search ##

How to configure the Windows 10 Hosts file

Open Notepad as an administrator. If you don't open it as an administrator, you won't be able to save the file.

In notepad, click file > Open, then navigate to C:\Windows\System32\drivers\etc

Select "all files" then open the hosts file.

Scroll to the bottom of the file and add a comment (comments start with a #).


# Blocked Sites #

# End Blocked Sites #

Save the file, then flush your DNS.

Restrict Access to your Hosts File

Learn how to restrict hosts file access to make it difficult to remove blocklists.

How to Flush DNS on Windows

On windows machines, open command prompt. Type "CMD" into your search bar and then open it.

Type ipconfig /flushdns then press enter.

How to configure the Mac Hosts File

Use finder to open Terminal

Type sudo nano /etc/hosts then press return. Enter your Macbook's password (must be an admin) when prompted and press return.

Use your arrow keys to scroll down the file. The mouse and keyboard don't work as you might expect when using terminal/nano.

Scroll to the bottom of the file and add a comment (comments start with a #).


# Blocked Sites #

# End Blocked Sites #

After adding the desired host entries, press ctrl+x and then shift+y to save changes. Then, flush your DNS.

Purge Porn From Your Life.

Get the most effective system for blocking porn on all your devices.

How to Flush DNS on Mac

If you haven't already, use finder to open terminal again.

Type the following command and press enter:

sudo killall -HUP mDNSResponder

If prompted for a sudo password, enter your administrator account password (probably the account you login to your mac with)

Start Purging Porn from your Technology Life.

Break the endless cycle of Porn addiction with blocking techniques that actually work. More

Step-by-step Tutorials

Watch videos that walk you through exactly what to do without any 'fluff'.

Internet Filtering

Get access to the best internet filtering used by corporations.