Want a free and effective way to block distracting websites on your Windows computer? Whether you’re aiming for better productivity or trying to keep your family safe online, editing the Windows hosts file is a powerful tool built right into your operating system. This method works universally across all web browsers on your PC without needing any extra software. This guide will walk you through every step of the process, from finding the hosts file to making sure your changes take effect immediately.
What is the Hosts File and How Does It Block Websites?
General shopping ads
Before a web browser connects to a website, Windows first checks the hosts file. The hosts file is a simple text document that can act as a local address book for website domains. You can manually create entries in this file to tell your computer where to go—or where not to go—when it tries to access a certain domain.
To block a website, we simply tell the hosts file to redirect that website’s address (like www.facebook.com) to a non-existent or internal IP address on your own computer. When your browser tries to connect, it gets sent to this dead end, and the website fails to load. It’s a surprisingly simple and effective trick.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Shopping ad
- Dimensions: 7.5" x 4.3" x 2.2". Compact size and lightweight make it easy to carry and put into your backpack, handbags or laptop bag without taking much space. Suitable for family use and daily organization. Note: Small mesh pockets are ideal for charging cords no longer than 3ft; longer cables (over 3ft) fit better in the larger compartments
- Quality Material: This electronic organizer travel case made of high quality durable waterproof oxford and soft sponge inside to secure your gadgets in place and deliver a quick access whenever you want. Water-resistant fabric protects your gear from unexpected splashes, keeping all your electronic essentials safe and secure
- Double Layers Design: This tech pouch features a double-layer interior design with 8 compartments, including multiple see-through mesh pockets and ample space to store your cords, cables, USB drives, cellphone, charger, mouse, flash drive and more, keeping all accessories neatly organized and tangle-free
- Practical and Convenient: Comes with a comfortable hand strap for easy carrying; You may carry it in your hand when heading out. Durable and smooth zipper closure keeps your favorite device securely, convenient for you to have quick access to the items inside the case
- Portable and Lightweight: The small size and lightweight design durable cable organizer pouch is a perfect choice when going on holiday, business trip, travel, office. Enjoy hassle-free travel without wasting time on tangled accessories. Great gift for yourself also a nice share with families and friends. (No include cords, electronic accessories)
Step-by-Step Guide to Blocking a Website
The process involves running Notepad with administrative rights, opening the hosts file, adding the websites you want to block, and then saving the file. Let’s break it down.
Step 1: Open Notepad as an Administrator
This is the most important step. The hosts file is a protected system file, so you need administrative privileges to edit it. If you try to open and save it normally, you will get a “permission denied” error.
- Click the Start button or press the Windows key.
- Type “Notepad” into the search bar.
- In the search results, right-click on Notepad and select Run as administrator.
- A User Account Control (UAC) prompt will appear. Click Yes to grant administrative permissions.
You will now have a blank Notepad window open, but this instance of Notepad has the power to edit system files.
Shopping ad
- 【UPGRADED LAPTOP CLEANING KIT 】 The macbook cleaning kit computer screen cleaner comes with a number of accessories including a retractable large brush, polishing cleaning cloth X 2, keycap puller, metal pen tip, flocking sponge, thin soft brush, soft plastic lens cleaning pen, 5 replacing cloth, large cleaning microfiber cloth. You deserve the comprehensive computer cleaning kit keyboard vacuum at a low cost
- 【PROFESSIONAL KEYBOARD CLEANING KIT】 The laptop screen cleaner keyboard cleaner can pull out the keycaps of gaming keyboards and mechanical keyboards. A retractable keyboard brush works on laptops and keyboards, while the mini high-density brush is great for deep cleaning between keys for cleaning between flatter keys on a laptop, the metal pin tip gently removes any stains. This electronic cleaning kit macbook cleaner totally meets professional cleaning needs
- 【OFFICE DESK ACCESSORIES】This keyboard cleaner kit is easy to use and can clean your keyboard and electronic screen with just one swipe. Wiping with the 2mm thicken widen polishing cleaning cloth designed at a right angle for better fitting screen corners of computers with our recyclable cleaning spray, The laptop cleaner kit for macbook effectively absorbs stubborn stains, leaves no discoloration, no streaks, and no fiber shedding on the screens
- 【MULTIFUNCTIONAL TOOLS 】Mini soft brush and soft plastic lens cleaning pen are specially designed for DSLR camera screen, lens, and other delicate surfaces. 5 more cleaning cloths of it supplied for replacement. The flocking sponge is an excellent tool for cleaning earbuds charging cases, And the earbud cleaning kit is ideal. This electronics for college students is equivalent to 10 other electronic cleaning kit
- 【PORTABLE DESIGN & CLEANER TOOL】 The office supplies is compact in design, easy to carry, and you can easily take it anywhere. It's convenient to keep one in a drawer, one in your car, or in your bag and dorm. It is easy to use and can clean your keyboard and electronic screen with just one swipe. Is the college essentials cleaning tool for your friends, family, colleagues and students
(Note: An illustrative image would be placed here in a live article)
Step 2: Open the Hosts File
Now that Notepad is running with the correct permissions, you need to navigate to the hosts file’s location.
- In Notepad, click File > Open.
- In the “File name” box, paste the following path and press Enter:
- C:\Windows\System32\drivers\etc
- By default, you won’t see any files because Notepad is looking for .txt files. Click the dropdown menu in the bottom-right corner that says “Text Documents (*.txt)” and change it to “All Files (.)”.
- You will now see several files. Select the file named “hosts” and click Open.
(Note: An illustrative image would be placed here in a live article)
Shopping ad
- Compatible Space: This electronics organizer bag features 2 zippered mesh pockets fits phones, standard power banks, 4 elastic loop pouches for small items, 2 elastic loop pouches for wireless headphones and small chargers. Elastic loops for phone charging cable. And specific slots for SD cards. Please check the size to ensure it meets your needs
- Lightweight Travel Accessories: The size of the electronic organizer travel case is 10.6" L x 7.5" W x 1.2" H, Compact but substantial size fits your intended bag or space. Suitable for traveling use and daily organization
- Keep Everything Organized: This compact travel organizer features dedicated compartments for your phone charger, cables, and tech accessories, keeping them tangle-free and ready to go. You can find travel accessories quickly, no chasing cords in your pack anymore
- Durable Travel Essentials: Features double zippers for easy access, elastic loops with non-slip grips for daily protection. Organizer for office use and traveling, (Not including cords, electronic accessories). It can serve as a travel checklist. Before you leave a place, just open the case and check if everything is there, preventing you from leaving things behind
- Versatile Use: Its practicality and convenience make it a travel essential bag. It is suitable for a weekend trip, business trip, and travel. This organizer pouch is suitable for office, business, daily use and can be given as a gift for friends, family, or men, for birthdays, Valentine's Day, Christmas Day, Father's Day
Step 3: Add Websites to the Block List
The hosts file will open, showing some text that explains its purpose. Any line that starts with a # symbol is a comment and is ignored by Windows.
To block a website, you will add a new line at the very end of the file.
Recommended Free Tools
- Go to the bottom of the file and start a new line.
- Type 127.0.0.1, press the Tab key or a few spaces, and then type the website address you want to block.
- For best results, you should block both the www and non-www versions of the site. Create a separate entry for each.
The IP address 127.0.0.1 is the “localhost” or “loopback” address. It’s your own computer’s internal IP address. By pointing a website’s domain to this address, you prevent your computer from reaching the actual site on the internet.
Shopping ad
- Universal fit: ColorCoral cleaning gel, simple and convenient cleaning kits for PC/laptop keyboard and other rugged surface, such as the car vent, camera, printer, telephone, calculator, Instrument, speaker, air conditioner, TV and other appliances
- Safe cleaning gel: The keyboard cleaner gel is made from natural gel, no sticky to hands, smells sweet with lemon fragrance, no stimulation to skin
- Easy dust cleaning: Make sure your hands are dry and clean, knead the cleaning gel into a ball, press the cleaning gel slowly into the keyboard, car vent and rugged surface till the cleaning gel could touch the bottom and then pull out, the dust would be carried away with the cleaning gel
- Reusable: The keyboard cleaning gel could be used repeatedly till the color turn to dark or it become sticky, then you have to replace the cleaning gel with a new one. After cleaning, please stock the cleaning gel in cool place. (Note: Don’t wash the gel in water.)
- In the package: 1 can of universal cleaning gel, we provide the cleaning gel with brand new, if you find the package broken, the cleaning gel dirty, or any other quality issues, please email us through message, we provide you new one soon
Example Block List:
To block Facebook and Twitter, you would add the following lines to the end of your hosts file:
# Block distracting social media sites
127.0.0.1 www.facebook.com
127.0.0.1 facebook.com
127.0.0.1 www.twitter.com
127.0.0.1 twitter.com
127.0.0.1 www.instagram.com
127.0.0.1 instagram.com
Step 4: Save Your Changes
Once you’ve added the websites you want to block, you need to save the file.
- Click File > Save.
- Close Notepad.
Since you opened Notepad as an administrator, it will save without any permission errors.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Shopping ad
- Award-Winning Compact Design & EDC-Ready Gift Choice: Weighing only 0.09 lb and sized like a credit card, this compact laser measure is designed for everyday carry. It slips easily into a pocket, tool pouch, or bag, and can attach to a keychain for quick access wherever you go. Its minimalist design, premium tactile finish, and practical one-button measuring make it a useful EDC gadget for DIYers, real estate agents, homeowners, and tech enthusiasts. A thoughtful gift for men on any occasion
- One-Button Easy Measuring, Simple to Use: Designed with simple one-button operation, this compact laser tape measure makes quick measuring easy without complicated controls. Just press to measure room dimensions, furniture spacing, window height, wall décor placement, and everyday distances around the home. Ideal for users who want a smart, pocket-size measuring tool that fits naturally into an everyday carry (EDC) setup and feels intuitive, modern, and easy to use
- Fast & Accurate Indoor Measurements with Class 2 Laser: Measure distances from 0.16 ft to 98 ft with up to ±1/16 in / ±2 mm accuracy. With quick measurement response in about 0.2 seconds, HOTO helps you check spaces efficiently for home renovation, furniture layout, moving, decorating, craft projects, and DIY planning. Built with a Class 2 laser for everyday indoor measuring; use as directed and avoid direct eye exposure
- Low-Power OLED Display & USB-C Rechargeable Convenience: The low-power OLED display provides clear indoor readings while helping reduce battery drain. With USB-C rechargeable design, auto shut-off, and up to 1000 measurements per charge, this digital laser measure is built for repeated daily use without frequent battery replacement. Compact enough to keep in a drawer, toolbox, bag, or pocket
- Useful for Home, Work & Everyday Projects: From home renovation and furniture measuring to room planning, real estate checks, interior design, and light construction projects, this pocket-size laser distance measure is made for practical everyday use. Compact enough to keep in a drawer, toolbox, bag, or pocket, it is a stylish measuring tool that feels just as giftable as it is useful
Step 5: Flush the DNS Cache (Important)
Windows keeps a cache of recently visited websites to speed up Browse. To make sure your changes to the hosts file take effect immediately, you need to clear this cache.
- Open the Command Prompt as an administrator (just like you did for Notepad in Step 1).
- Type the following command and press Enter:
DOS
ipconfig /flushdns
- You will see a confirmation message: Successfully flushed the DNS Resolver Cache.
This command forces Windows to reread the hosts file for any future website requests.
How to Test and Unblock Websites
Testing: To test if the block is working, simply open any web browser and try to navigate to one of the websites you added to the hosts file. You should see an error page saying the “site can’t be reached” or something similar.
Unblocking: To unblock a website, simply follow the same steps to open the hosts file as an administrator and either:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesMore shopping ads
- Delete the lines you added.
- Or, place a # symbol at the beginning of each line to turn it into a comment, which makes Windows ignore it. This is a good way to temporarily unblock a site without having to re-type the line later.





