Nginx process is running as root even the Local.app is quit

This is very frustrating. It makes it difficult to use Local alongside another server. In my case, I want to run MAMP Pro and Local side by side.

Here’s how MAMPs servers work, for comparison:

When the MAMP front-end application is launched, it starts the servers (NGINX/Apache/MySQL/etc.). Like Local, the servers will continue to run after the MAMP application is closed. The difference is that in MAMP there is a big button labelled “Servers”, which will stop and start the servers.

Local has no such button, so once NGINX is running there is no GUI to stop it, and thereby free up ports for MAMPs servers.

In addition, Local has a launch daemon that starts NGINX on system boot, which means even if you haven’t started Local, it hijacks the ports anyway.

Currently if you want to free up those ports you need to kill Local’s NGINX processes. On macOS:

sudo /Applications/Local.app/Contents/Resources/extraResources/lightning-services/nginx-1.16.0+3/bin/darwin/sbin/nginx -c "/Users/username/Library/Application Support/Local/run/router/nginx/conf/nginx.conf" -p "/Users/username/Library/Application Support/Local/run/router/nginx" -s stop

(You will need to change “username” to your macOS username. And note that the path to NGINX might change in future versions of Local).

After issuing that command NGINX will gracefully shutdown, and ports 80 and 443 become available.

However, you will need to manually restart Local’s NGINX server if you want to use Local again (or reboot your computer, ugh):

sudo nohup /Applications/Local.app/Contents/Resources/extraResources/lightning-services/nginx-1.16.0+3/bin/darwin/sbin/nginx -c "/Users/username/Library/Application Support/Local/run/router/nginx/conf/nginx.conf" -p "/Users/username/Library/Application Support/Local/run/router/nginx" -g "user root staff;" &

(Again, change “username” to your macOS username).

I humbly request that Local’s developers:

  1. Add a “start/stop servers” button inside the application.
  2. Add an options allowing the user to decide if Local’s servers should start on system boot.

EDIT: I have made a feature request. Please vote for it is you think this functionality is important.