Localhost on Mac is taking long time to resolve

If you are using Mac OS X with MAMP (Mac Apache MySQL PHP) installed in your OS and you are still scratching your head asking why “localhost” or MAMP starting page “localhost/mamp” is taking ages to load. Yes, you are having the same problem that i had previously.

First of all, please make sure your “locahost” is not incorrectly mapped in your hosts file.

  1. Kindly open Terminal (or you can hit Command + Shift + U then double click on Terminal)
  2. enter command “sudo nano /private/etc/hosts” and enter your admin password.
  3. Ensure the following entries in your file. No duplicate of 127.0.0.1
    127.0.0.1 localhost
    255.255.255.255 broadcasthost
    ::1 localhost
    fe80::1%lo0 localhost
  4. Control + O, Control + M and Control + X to save and exit the file

If your hosts file is correct. Please check your Activity Monitor for any suspicious running backend process. (You can find the Activity Monitor in Utilities Command + Shift + U)

In my case, there is this “mdworker” process which was taking high %CPU!

After googling of this mdworker (here), this is actually a ‘metadata server worker’ used as search engine for Spotlight. In the referenced article, it is shared that this process will search into your external hard drive and apparently I just had my 1TB external hard drive plugged into my MBA! And it is also running Time Machine Backup job.

For those who don’t really need their external hard drive to be indexed in Spotlight, you can actually exclude this mdworker from crawling your external hard drive

Resolution

  1. Simply go to System  > Spotlight
  2. Under Privacy tab, click Add button to include all your external hard drive partition into the “Prevent” list.

Mac OS Localhost slow   Woah la~

And if you do not wish to exclude your external hard drive from indexing. All you can do is to wait until the indexing is completed. 🙁

Leave a Reply

Your email address will not be published. Required fields are marked *