Windows PC
- Open Search: Press the Windows key and type
Notepad. - Run as Admin: Right-click Notepad in the search results and select Run as administrator.
- Open File: In Notepad, go to File > Open.
- Navigate: Paste the following path into the address bar and press Enter:
C:\Windows\System32\drivers\etc\hosts.- Note: If you don’t see the file, change the file type dropdown from “Text Documents (.txt)” to “All Files (.)”*.
- Edit and Save: Make your changes, then press
Ctrl + Sor click File > Save.
macOS
To edit the macOS hosts file as an administrator, use the Terminal to open the file with sudo privileges. Run sudo nano /etc/hosts, enter your password, make changes using the arrow keys, and save with Control+O, Enter, and Control+X.
- Open Terminal: Press
Command + Space, type “Terminal”, and hit Enter. - Open File with Sudo: Type the following command and press Enter:
sudo nano /etc/hosts - Authenticate: Enter your Mac user password (it will not appear on the screen) and press Enter.
- Edit: Use the arrow keys to move to the bottom of the file. Add your new mappings (e.g.,
127.0.0.1 example.com). - Save and Exit:
- Press
Control + OandEnterto save the changes. - Press
Control + Xto exit nano.
- Press
- Flush DNS Cache (Optional): To make changes take effect immediately, run:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder