I run Apache on my Macbook Pro for off-line use of a web app. But for "self-defense" online, I use /etc/hosts to map certain hostnames to which means if a webpage causes a GET to one of these, it hits my local webserver instead.

I would rather they do nothing. If I point them to an address that I know is unreachable, e.g.,, then a poorly designed web page may not render until the GET times out.

In 10.13.4, how do I (Can I) point them to a separate private address that will be handled on the Macbook and set that address to immediately reject everything? (Without changing how loopback behaves.)

(By the way, Apple documentation has long claimed that /etc/hosts is only used in single-user mode. I have found that to be false on many versions of OS X/MacOS.)

  • Can you change the port number for your local Apache instance?
    – Mike Scott
    Apr 24, 2018 at 8:51
  • Actually, that could be done, thanks. It would have the added bonus of making it harder for someone to get in from outside. Still would like to know about the other, though.
    – WGroleau
    Apr 24, 2018 at 13:15
  • How is this "multi-homed"? There's not two or more discreet networks here.
    – Allan
    Apr 24, 2018 at 15:11
  • already exists. If I add another address (somehow), isn't that multi-homed?
    – WGroleau
    Apr 24, 2018 at 15:17
  • is a loopback not a network
    – Allan
    Apr 24, 2018 at 15:55

1 Answer 1


The easiest way to achieve a guaranteed reject with no timeout is to use a broadcast address Edit your /etc/hosts file and for hosts that you want request rejected put an entry such as:  rejectedhost.com  someotherhost.net

This free and simple technique can also be used to block out advertisement hosts on ad-ridden or popup-ridden web pages.

  • Although it doesn't technically answer the question, I'm accepting it because it is a better solution than the one I asked about. Thanks
    – WGroleau
    Apr 24, 2018 at 16:27
  • Great technique, thank you. I'm using it to block popunders.
    – jetset
    Jul 30, 2018 at 21:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .