MAMP Error: Hosts File Couldn’t Be Written

By Daniel Espinoza on Oct 21, 2011 | Developer

Recently I was working on a few sites locally and noticed that MAMP wasn’t working.  I restarted my machine, and restarted MAMP, but MAMP still wouldn’t complete startup.  The only error received was “Error: The file /etc/hosts couldn’t be written.”  The error stemmed from an invalid hostname – one that ended with a “dash”.

There were no instances of httpd or mysqld running, so I figured that MAMP was running into an issue when trying to startup.   The entire GUI was locking up even after I pressed the “OK” button.

 

Contrary to the reported error the /etc/hosts file was writeable  so the issue was somewhere else.  The contents of the /etc/hosts file were changed to include several of my defined hosts and a null entry:

127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost

127.0.0.1 (null)

Several forum posts said that this null item needed to be removed from the hosts file and also from the MAMP definition.  I was able to clear out the hosts file but the null item would reappear each time I started MAMP.

MAMP has an option to “Start Apache and MySQL when starting MAMP Pro”  which I had selected. Because of this and the GUI locking up, I wasn’t able to get to the Hosts tab to remove the errant item.   Based on this post I found the preferences file in ~/Library/Preferences/de.appsolute.mamppro.plist.  The plist file is binary and can’t be edited directly, so I renamed it and restarted MAMP.  The plist file was recreated and although I lost my hosts definitions, I was able to get back to work.

Here are the steps to fix:

  1. Close MAMP
  2. Kill any httpd or mysqld processes
  3. Clean out /etc/hosts file
  4. Rename/remove ~/Library/Preferences/de.appsolute.mamppro.plist file

 


Share |

No Comments

Sorry, the comment form is closed at this time.