Launchd not loading nginx on startup Launchd not loading nginx on startup nginx nginx

Launchd not loading nginx on startup


This is what worked for me:

sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchDaemonssudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist

The trick to this is that Mac OSX won’t let anything other than “root” or “system” level services use a port number below 1024.

Read more here: http://derickbailey.com/2014/12/27/how-to-start-nginx-on-port-80-at-mac-osx-boot-up-log-in/


I stumbled upon your question because I was having the same issue. Three things helped me make it work:

  • change ownership of plist file to root:wheel (sudo chown root:wheel /usr/local/opt/nginx/*.plist)
  • create the symlink in /Library/LaunchAgents instead of ~/Library/LaunchAgents, because you probably run nginx on port 80, which requires root privileges.
  • Remove the <string>-g</string> and <string>daemon off;</string> lines from the plist (before loading it with sudo launchctl load /Library/LaunchAgents/homebrew.mxcl.nginx.plist)

I'm not sure why those two lines are invalid, but I found out by trying to execute the /usr/local/opt/nginx/bin/nginx with -g daemon off; added to it, it also failed.