开发者

/etc/hosts file permission Mamp Pro

I'm running MAMP and it's telling me that it can't write to the /etc/hosts file. I'm guessing it's a permission issue but not totally sure. This is the error:

The file /etc/hosts couldn't be written

Any tho开发者_StackOverflow社区ughts?


Go to your hosts file (/etc/hosts) and delete this line

127.0.0.1 (null)


On you mac, via the go to folder command (or cmd-shift-g) go to /etc/hosts. You will likely find that your hosts file is locked. Do a get info (cmd-i) on the file and uncheck 'locked'. Also check to see if you have write or read-only permissions under "Sharing and permissions". This is what I did and now my MAMP Pro works 100%


You might want to read this: http://www.justincarmony.com/blog/2011/07/27/mac-os-x-lion-etc-hosts-bugs-and-dns-resolution/


I used Arend solution and commented the 127.0.0.1 line on my host file using Terminal. When you open Terminal type sudo nano /private/etc/hosts and you'll be asked for your password. With your cursor navigate to the line with the 127.0.0.1 and comment it by adding a # before. Then press Control+X and answer Y and MAMP worked fine as usual.


I'm not sure if this will help with your issues, but I just reinstalled mamp pro so I had the problem again, which I have fixed previously.

Open Mamp Pro > Hosts > There will be a box in the centre titled "Disk Location" which will say something like "/Applications/MAMP/htdocs" under which it has a button that says Permissions. Click this, in the area that is called "Permissions" and has a bunch of check boxes, you simply the the "W" checks in the directory row and click "Set". Voila.


I have the same problem with MAMP Pro 2.0.5. It seem like MAMP Pro won't work if you edited your etc/hosts file (eg, put in extra text...)


Your guess that it's a permissions issue seems reasonable. To investigate this further, you can try the following:

  • What account does MAMP run under?
  • If you log in as this account, can you edit /etc/hosts
  • Does the account need to be in a specific group to get access to /etc/hosts

Bear in mind that allowing an application to modify /etc/hosts is a security risk, which is why it is secured with strict permissions in the first place.

A quick RTFM at the MAMP documentation http://documentation.mamp.info/en/mamp-pro/hosts/general shows that there is a check-box (Local Name Resolution) to control whether or not MAMP writes to the hosts file. My suggestion would be that you uncheck this check-box, and then manually edit your hosts file using a suitably privileged account to add the names you wish to use.


I'm having this exact problem with 2.0.5... I'm given the message Can't write to /etc/hosts, underneath which appears another error message that says something along the lines of "IDN to ACE conversion failed at hostname". This is, after many hours, completely infuriating.

I've uninstalled MAMP & MAMP Pro several times, which does not a thing to resolve the problem. /etc/hosts is easily writable using sudo.

I've also tried using XAMPP, to circumvent the problem, but I'm not terribly skilled at server admin, and can't seem to get vhosts properly set up.

I'm about to pull my teeth out, and reinstall os x. I'm turning to Stackoverflow, as the MAMP forum has been just about useless


I've circumvented the problems I've been having with MAMP Pro 2.0.5 by resorting to the non-paid version of MAMP, and manually creating virtual hosts per ---> http://sawmac.com/mamp/virtual/


for anyone else having this problem. My fix was to uninstall mamp pro and the standard version too by using their uninstall apps located on their own folders in /Applications. I got erros about two folders not being able to be erased. I don't remember which ones but if the problem you're having is same as mine was, you'll get a prompt of folder names. Folders were located in:

~/Library/Preferences
~/Library/Application Support

I deleted those manually and restarted the uninstall app. I also deleted the following two files from the ~/Library/Preferences folder:

de.appsolute.MAMP.plist de.appsolute.mamppro.plist.lockfile

Rebooted and installed Mamp Pro.


I just had this issue under v3.5 and solve it by uncheck 'locked', checking "Sharing and permissions" and finally commenting out this line:

# 127.0.0.1 localhost


I realise that this is a very old question. However, I have recently hit exactly this issue when trying to use MAMP Pro with El Capitan.

I too was receiving the same "The file /etc/hosts couldn't be written" error. However, none of the solutions above worked as (after some research) I discovered that the issue was caused by the System Integrity Protection (SIPs) that was added with El Capitan. - In order to allow MAMP to update the hosts file this needs to be switched off.

  • Click the apple menu.

  • Select Restart...

  • Hold down command-R to boot into the Recovery System.

  • Click the Utilities menu and select Terminal.

  • Type csrutil disable and press return.

  • Close the Terminal app.

  • Click the apple menu and select Restart....

If you decide later you want to re-engage SIPs (and I hope that you do), repeat these steps, changing csrutil disable to csrutil enable instead. I personally would re enable it as SIPs was added for your protection.

The above steps were cut and pasted from the following article:

http://www.imore.com/el-capitan-system-integrity-protection-helps-keep-malware-away

Please be aware of the warning about disabling this protection - It is there for a reason. I personally go offline then disable SIPs, make my change, then re-enable it, go back online.


You should be able to run as sudo.

sudo nano /etc/hosts

You can then make your amends and refresh the DNS caching.

dscacheutil -flushcache
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜