[Solution] Nginx [emerg]: bind() to 0.0.0.0:80 failed (13: Permission denied)

I installed nginx using homebrew on my Mac Snow Leopard 10.6.

I was getting following my error:

02/12/10 1:18:45 PM org.nginx[1651] [emerg]: bind() to 0.0.0.0:80 failed (13: Permission denied)

Solution

Homebrew creates a nginx startup config file at ~/Library/LaunchAgents/org.nginx.plist

I moved it to /System/Library/LaunchDaemons/org.nginx.plist

Difference is when Nginx started from ~/Library/LaunchAgents, it started under a normal user account but when it started from /System/Library/LaunchDaemons/ is started under root account.

If above doesn’t fix your issue, you can open org.nginx.plist and check if it contains a key-value pair like below:

<key>UserName</key>
<string>rahul286</string>

Replace rahul286 with you UserName. You can find your username by running $whoamicommand.