Solving IP loopback problem

[Related to: Use Mac as a Web Server]

Your Mac, which is also the webserver, is behind a router. You enter your website's domain name on your web browser. You cannot connect. You can still connect via your internal IP address, so the webserver is not down. What gives? Here's what might be happening.

If you're running your computer as the webserver behind a router, and if the router cannot 'loopback' to its own IP address, you might not be able to access your own website on your own computer under the domain name you registered. Since the IP address that the domain name is tied to is the external (i.e. router's) IP address, and your router cannot loopback to itself and let you access the internal address by that address, entering the domain name on your web browser in attempt to access your own website will end in failure.

So how do you configure your Mac so you can connect to your own website by the domain name? Here's a very good tip that gray, an ArsTechnica OpenForum member, wrote about.

What we need to do is modify some information on NetInfo. There is a graphical version and a command line version. In this case doing it on command line is simpler and quicker. Open up Terminal and type this (it's in ONE LINE):

sudo nicl . -create /locations/lookupd/hosts LookupOrder CacheAgent NIAgent FFAgent DNSAgent

Be careful, as that's N-I-C-L, nit N-I-C-1. And yes, there's a period between that and -create. What this basically does is to re-order the priority of the lookup daemon so that it checks NetInfo before DNS. This has to be done correctly if the next line is going to work. Type this now:

sudo nicl . -create /machines/localhost name localhost mydomain

Replace mydomain with your website's domain name (e.g. If you want to add more domain names, add at the end of the line separated by blank. What this does is to add your domain name as an alias to the localhost hostname. In other words, when you enter your domain name on your web browser, it will be treated like entering 'localhost', and you will immediately be connecting to your website.

We're not quite done yet, though. We need to have the lookup daemon recognize these changes. Type like this:

sudo kill -HUP 'cat /var/run/'

You should now be able to access your website via your web browser using the domain name. This is useful, and may be necessary in many occasions, as you need to enter the domain name information in configuring such systems as phpBB or s9y.

Later on, if you want to add/change/delete the domain name, you can run the NetInfo Manager and do it graphically. Run the application and unlock (click the lock and enter the admin password). Go in the order of '/ - machines - localhost'. Click the triangle next to the 'name' at the bottom pane to reveal the values. To edit an existing entry, double-click on the value you want to edit. To add a new entry, choose 'Directory - Insert Value' from the menu. To delete, choose 'Directory - Delete Value'.


Trackback specific URI for this entry

This link is not meant to be clicked. It contains the trackback URI for this entry. You can use this URI to send ping- & trackbacks from your own blog to this entry. To copy the link, right click and select "Copy Shortcut" in Internet Explorer or "Copy Link Location" in Mozilla.

Wesley's Tool-Box on : Server upgrade didn't go well

Continue reading "Server upgrade didn't go well"
This morning saw Apple announcing the first official Macintosh computers with Intel CPU such as the MacBook Pro. These machines come with OS X 10.4.4 for Intel, and Apple updated the PPC version of OS X to the same version. I downloaded the update and ran


Display comments as Linear | Threaded

Ollie on :

I'm delighted to find an article describing exactly what I want to achieve - thanks for posting it.

Your command for adding a domain name works beautifully - unfortunately my LookupOrder does not seem to be affected by the first command (I cut and pasted it).

Could this be because the last command failed?
This is the reulting line in Terminal:
kill: illegal process id: cat /var/run/

Instead I tried :
sudo killall -HUP lookupd

but I really have no idea what I'm doing.

Any suggestions?
  • Link

  • Warning: Undefined array key "is_entry_owner" in /Users/Wes/Website/Documents/blog/templates_c/next_toolbox/50/11/8a/50118ab468ecea5f9b44a283f14ab4f275c0b22d_0.file.comments.tpl.php on line 81
  • Reply

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

Copyright (C) 1996-2023 Woo-Duk Chung (Wesley Woo-Duk Hwang-Chung). All rights reserved.