Posted inPrivacy / Security

Gas Mask: A Simple Hosts File Manager for macOS

Gas Mask hosts file editor banner showing a figure wearing a gas mask

Maybe I should start by explaining what a hosts file is. It’s a plain text file that tells your computer which IP addresses to associate with specific hostnames. You can use it to access a local development server by name or prevent connections to known advertising, tracking and malware domains.

Gas Mask is a free and open source hosts file manager for macOS that lets you switch between different configurations. But there’s something you should know before installing it on a current Mac.

Updated: November 2026. The original screenshots date from 2017. Current Gas Mask compatibility has not been tested.

Does Gas Mask still work on macOS?

The available official releases page identifies 0.8.6 as the latest distributed version. The source repository contains newer changes, including a changelog entry for 0.8.7 and an Apple Silicon build script. The available repository README lists macOS 13 Ventura or later. That statement does not establish compatibility of the older downloadable release with current macOS versions.

The distributed app is listed by Homebrew as an Intel app requiring Rosetta on Apple Silicon. Apple confirms that Rosetta remains available through macOS 27, but general support for Intel apps ends with macOS 28. I haven’t established that Gas Mask’s downloadable version, including its privileged hosts file editing functionality, works on macOS 27.2.1. Being able to launch an app isn’t the same as being able to use all its features.

Homebrew’s listing also records September 1, 2026 as the cask’s disable date. I wouldn’t rely on the old Homebrew installation command or bypass macOS security checks to get Gas Mask running. You can edit the hosts file manually without installing anything, as explained below.

How the hosts file works on macOS

In macOS you can find the hosts file in /etc/hosts. The system resolver uses its entries alongside DNS results. Each entry consists of an IP address followed by one or more hostnames, separated by spaces or tabs. A line starting with # is a comment. You can read the format documentation by running man 5 hosts in Terminal.

To block a particular hostname, you can append a line like this:

0.0.0.0 example.com

Alternatively, 127.0.0.1 example.com points the name at your own computer. I prefer 0.0.0.0 for blocking because it avoids deliberately directing traffic to a local web service. Use one mapping, not both. example.com is just an example; replace it with the hostname you actually want to block. An entry for example.com doesn’t automatically block www.example.com or every other subdomain.

If all you want to do is block ads and trackers, you can also use AdGuard DNS without editing your Mac’s hosts file.

Back up, edit and restore your Mac’s hosts file

First, always back up the original file. In Terminal, run:

sudo cp -p -n /etc/hosts /etc/hosts.before-gas-mask &&
sudo cmp /etc/hosts /etc/hosts.before-gas-mask

You’ll need an administrator account. The first command preserves file attributes and doesn’t overwrite an existing backup. The second runs only if the first succeeds and compares the contents; if both commands complete without errors or differences, the files match. If the backup name already exists and belongs to an earlier configuration, choose a new unused filename and use that name when restoring. Don’t proceed if the backup fails.

To edit the active file manually, run:

sudo nano /etc/hosts

Add your entries at the bottom. Preserve the existing localhost entries, including 127.0.0.1 localhost, ::1 localhost, the 255.255.255.255 broadcasthost entry if present, and any other mappings required by your Mac, VPN or development tools. Don’t replace the entire file with an unreviewed download. In Nano, press Control+O, Return and Control+X to save and exit.

If the change isn’t reflected immediately, the following commands are commonly used on macOS to clear resolver caches:

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

Restart the affected app if necessary. You can check the system’s hostname lookup with:

dscacheutil -q host -a name example.com

Use the hostname you edited. This checks name resolution, not whether every application will honor the mapping. Tools such as dig query DNS directly and aren’t a reliable test of the hosts file itself.

To restore your previous configuration, quit Gas Mask first if it’s running so it doesn’t reapply its active profile, then run the following using the backup you actually created:

sudo cp -p /etc/hosts.before-gas-mask /etc/hosts
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

This restores your own previous file, which may contain custom entries, rather than guessing what a factory default hosts file should look like.

Where to find hosts lists

Luckily you don’t have to collect every unwanted domain manually. There are a bunch of hosts lists available, including these two sources:

Both projects provide public lists and ways to report mistakes. That doesn’t mean every entry is safe or correct. Download and inspect a list before applying it, preserve your original system mappings and avoid unexpected redirects to public IP addresses. A list can break legitimate websites, sign in flows or app services. HTTPS protects the download in transit but doesn’t establish that its contents are trustworthy. I wouldn’t enable automatic updates from a source you haven’t reviewed.

Using Gas Mask to manage hosts files

Or… you can use Gas Mask if you already have a version that works on your Mac.

The developer’s documented manual installation method is to download the app from the official releases page, extract the ZIP and move Gas Mask into Applications. On the first launch it requests administrator authorization to modify /etc/hosts. On Apple Silicon, an Intel build also needs Rosetta. If the app is blocked by macOS or fails to obtain authorization, stop and use the manual method above. Don’t disable Gatekeeper or System Integrity Protection to install this utility. The download asset and installation have not been independently tested for this update.

Gas Mask menu bar menu with Original File selected and an option to show the editor window

With Gas Mask, you can edit hosts files, create multiple configurations and switch between them on the fly. The project’s user guide describes three types:

  • Local: files saved on your Mac that you can edit.
  • Remote: files downloaded from URLs and refreshed at an interval you configure. Local edits to these files won’t survive a refresh. Use the raw HTTPS text URL, not the GitHub page displaying the file. HTTPS download behavior in the old distributed version has not been retested.
  • Combined: a configuration made up of selected local and remote files. It lets you switch on several sets of entries at once.

The editor initially includes a copy of your original hosts file. Keep your independent backup too. Use the Create button to add a configuration, then Activate to apply it. You can also switch files from the menu bar. Check that your active configuration includes the necessary system entries, and don’t combine conflicting mappings. The app replaces the contents of /etc/hosts with the active configuration; don’t assume it merges your existing entries automatically.

Gas Mask has historically been described as clearing the DNS cache when switching files. I couldn’t verify that behavior for the current distributed build on modern macOS. Check the active file and resolver results after activating a profile; use the manual cache commands above if necessary.

Gas Mask editor showing the Original File profile and hosts entries with Create, Remove, Save and Activate controls

Is a hosts file enough to block ads and trackers?

The hosts file can affect multiple applications that use the system resolver, not just your browser. But it works at the hostname level. It can’t distinguish an ad from the content you want when both use the same hostname, remove empty ad spaces, filter URL paths or block connections made directly to an IP address. Applications that resolve names independently may bypass it. It isn’t antivirus software or a guarantee against tracking.

A browser content blocker can apply more specific rules to web requests and page elements. DNS filtering can block domains for devices using a filtering resolver, and may offer centralized updates and allowlists, but it has similar limitations when ads and wanted content share a domain. A hosts file only changes the machine on which you edit it.

If you’re not comfortable messing with the hosts file, I’d suggest using a browser content blocker instead. For Firefox, there’s uBlock Origin. The full extension is no longer available for current Chrome. For Chrome, Edge or Safari, check out uBlock Origin Lite, which uses a different extension API and doesn’t provide all the features of the full version.

You can also read our AdGuard overview for the differences between browser extensions, standalone filtering and DNS filtering. On Linux, see our hosts file article featuring hBlock (an older tutorial whose installation instructions are version specific).

Support FSMdotCOM on Liberapay