macOS: nging not starting with brew

Manish Kumar
2 min readMar 22, 2021

Recently I encountered a problem with my mac machine while starting nginx. I have installed nginx via brew command. When I used to start nginx it was giving me the error status.

brew services start nginx

This was giving me hard time. I had uninstalled it and cleared all the files but it appears that doing so did not solve my issue.

Reason: Upon doing some research I found out that the actual issue was somewhere else. The issue was here:

Go to /usr/local/var/log/nginx/ location and do ls -lrt.

The actual owner for the error.log and access.log file has changed to root user. These are the default error log and access log files for the nginx. If you try starting nginx with the sudo then it will work, but that is not an exact solution.

sudo brew services start nginx // might work but not an exact solution.

The solution was to change this owner to yours machine user. How would you do that? Well, chown is at rescue here.

sudo chown -R $(whoami) /usr/local/var/log/nginx/

Happy Learning!!!

--

--