"Host Files" and Macintosh osX

You ever wonder why some commercial web sites load so slow and seam to get to a point then just "hang" there waiting for soemthing. In most cases the hang time is the web site looking to load a file (banner) from a third party web site like adsonar.com, doubleclick.net, etc.

To prevent many of these hangs is to simply block access to this ad.doubleclick.net domain. You may also block any other problem domains or even other ad-only domains that you wish to block in this way.

The best way to do this is to simply assign the Internet address to ad.doubleclick.net (or any other problem or undesired domain). This way if your browser comes across a link to ad.doubleclick.net it won't try to look it up online (which is what triggers lookupd to crash) and instead will just use the address which is nothing more than an alias for your own local Mac. You could use the address instead if you wish, since that also is like an alias to your own local Mac. This fix doesn't really change how your Mac is running, all it does is ignore links to any domains you wish to block.

There are other more drastic fixes such as unlockupd, that will kill and restart lookupd at regular intervals, or you can adjust the timing of how lookupd uses its cache. I'd try this hosts blocking fix first though, since it doesn't affect how your system runs.

If you think you may have a different domain that's triggering the same hang. You may be able to isolate it by surfing to the problem site with Safari's Activity window open. Watch the Activity window as the page loads to see if you can identify any URL's that cause Safari (or what ever browser your using) to hang. If you find such a URL, you would simply add a new line using the domain portion of the URL, which is between the second and third forward slash, as follows.
For example. If you suspected a URL that looks like this:
You would simply add an additional line in the following steps that looked like this:   some.site.com (seperated by a "TAB")

Implementing A Host File Change
You'll need administrator access to follow these steps. Use This Information At Your Own Risk!
  • Launch terminal application, which can be found in:
    [Your Hard Drive] > Applications > Utilities > Terminal.app
  • Check the current hosts file by typing:
    cat /etc/hosts
  • Which should print out the following:
    # Host Database
    # localhost is used to configure the loopback interface
    # when the system is booting. Do not change this entry.
    ## localhost broadcasthost
    ::1 localhost
  • Backup the current hosts file to a file named hosts.original by typing:
    sudo cp /etc/hosts /etc/hosts.original
  • Enter your administrator password when prompted.
  • Copy the current hosts file to the Desktop by typing:
    cp /etc/hosts ~/Desktop/hosts.txt
  • Double click the hosts.txt file that appears on the desktop to open it in TextEdit
  • Add the following Internet address assignments to the end of the file: js.adsonar.com ad.doubleclick.net
  • Add similar lines for any additional domains you wish to block.
  • Select File > Save
  • Copy the edited file back into the /etc directory by typing the following:
    sudo cp ~/Desktop/hosts.txt /etc/hosts
    (Note: There is no ".txt" extension on /etc/hosts)
  • Verify that the changes were made properly by again typing:
    cat /etc/hosts
  • Which should print out the following which now includes the adsonar info:
    # Host Database
    # localhost is used to configure the loopback interface
    # when the system is booting. Do not change this entry.
    ## localhost broadcasthost js.adsonar.com ad.doubleclick.net
    ::1 localhost
  • Restart lookupd by typing the following (or by just restarting the Mac if easier):
    sudo killall -HUP lookupd
  • Now to test the fix, launch Safari and enter the following in the address bar:
    (NOTE: just type "js.adsonar.com", without quotes. Don't add a "www" or anything else.)
  • You should receive the following error if the adware site is successfully blocked:

    If you have Personal Web Sharing enabled, you may see the Apache start page instead.
  • Quit Terminal.
If anything goes wrong, or anytime you wish to revert back to the original hosts file simply follow these additional steps:
  • Launch terminal, which can be found in Applications/Utilities.
  • Move the backed up hosts file to its original location by typing this:
    sudo mv /etc/hosts.original /etc/hosts
  • Enter your administrator password when prompted.
  • Restart lookupd by typing the following (or by just restarting the Mac if easier):
    sudo killall -HUP lookupd
  • Quit Terminal.
The above fix could really be done in 2 or 3 steps (or even all in one step if you really know what you're doing), but I've included other steps that have you check the file and back it up first, then check again, etc. I also included steps so you can revert back to the original at any time if you wish. I've presented each step by itself, so that it's easy to follow by a Mac user who may not be Unix savvy.

Multi-Server Domain Names
Several of the larger commercial internet service web sites, such as Yahoo, Google, eBay and even FaceBook. Use multiple web servers for a single domain name. The system is usually called a "Wild Card" network. When a user enters the domain name the DNS proxy randomly redirect the the user to one of a group or mirrored servers (using cloned databases most the time). This spreads the bandwidth usage across multiple servers lets more people uses the site congruently without slowing down the load time.

Domain names using Wild Card server systems can't be blocked by just listing the domain name. For example FaceBook.com
Will NOT block there site. To block FaceBook.com you have to line list of 50 server entries including there hard coded IP numbers and over a dozen host servers. Including: FaceBook.com www.FaceBook.com videos.FaceBook.com vmta01.FaceBook.com vmta02.FaceBook.com vmta03.FaceBook.com

Blocking Additonal Web Sites (Parental Controls)
This same method can be uses as a very effective parental control. By listing the righ servers you can permanently stop access to potentially dangerous web sites such as FaceBook.com, Yahoo Chat Rooms, message boards and even Instant massager software such as Microsoft, AOL and Yahoo Messengers.

Sample Hosts file
Below is my current host files which blocks several ad servers as well as FaceBook.com, Instant massagers and message boards. These companies are in business to make money and aren't stupid. They can change up there server names any time to bypass known blocks. So this isn't a one time fix, but a start to a method of blocking unwanted information.
Click Here to download my current host file. (October 13, 2016 - 29,693 Unique Domains)
Click Here to download "github.com" host file.

Windows Hosts file
Location of Windows Hosts file:
(you may need administrator access for Windows NT/2000/XP/8/10)
Click Here more windows help.