I just installed Nginx on Mac OS X (thanks http://www.kevinworthington.com/nginx-mac-os-snow-leopard-2-minutes/), but how do I restart Nginx on Mac OS X?


  • 3
    If you just want to restart because of an updated config then just do sudo nginx -s reload.
    – hobbes3
    Mar 16, 2013 at 21:26

9 Answers 9

sudo nginx -s stop && sudo nginx
  • 1
    Quick question what does the && means? I guess it's something different then using ;?
    – hobbes3
    Mar 15, 2013 at 20:03
  • 3
    @hobbes3 stackoverflow.com/questions/6152659/…
    – cbednarski
    Mar 16, 2013 at 2:12
  • 5
    this answer is not working for brew installed nginx
    – vearutop
    Aug 9, 2015 at 4:43
  • 1
    It seems to work for my brew installed nginx in 2019. Oct 22, 2019 at 9:45
  • It doesn't work for my brew installed nginx.
    – ABCD
    Feb 4, 2021 at 20:01

For a one-liner, you could just do:

sudo nginx -s reload

The -s options stands for signal, and is the option you'll use to send stop, quit, reopen and reload signals to nginx.

For more info on the options, just do nginx -h for a list of all of them and their functions.


  • 2
    This did not work for me so I had to actually do sudo nginx to get it to start. I think it had something to do with nginx already being stopped in my case.
    – james-see
    May 19, 2016 at 17:40
  • 1
    Could you do sudo nginx -s reload || sudo nginx instead? Jul 1, 2019 at 13:38

for brew installation: sudo brew services restart nginx

  • 1
    This command dosn't work for me at all. I install nginx via brew...
    – kris_IV
    Dec 22, 2018 at 18:37
  • 1
    @kris_IV what is the output?
    – dimaninc
    Dec 23, 2018 at 8:29
  • 1
    after start: brew services restart nginx i get response: Stopping nginx... (might take a while) ==> Successfully stopped nginx` (label: homebrew.mxcl.nginx)` ==> Successfully started nginx` (label: homebrew.mxcl.nginx)`
    – kris_IV
    Dec 25, 2018 at 11:32
  • 1
    @kris_IV and why do you think this command not working then? everything is fine according to your output
    – dimaninc
    Dec 25, 2018 at 20:47
  • 2
    It looked good on brew services restart nginx
    – ABCD
    Feb 4, 2021 at 20:02
sudo pkill nginx   
sudo nginx

If the pkill can't be found, then install it using brew install proctools first.

  • 3
    The above answers are much cleaner than this and enable nginx to stop gracefully.
    – Mike N
    Sep 15, 2016 at 7:56
  • 1
    This came in handy when nginx started misbehaving and I couldn't kill it with sudo nginx -s quit or sudo -s reload
    – paperclip
    Oct 18, 2016 at 11:34
  • 1
    This is the only thing that worked for me. Thank you.
    – A-Dubb
    Apr 19, 2018 at 22:04

If you are using brew:

To see all services:

brew services list

Start nginx service:

brew services start nginx

Stop nginx Service:

brew services stop nginx

sudo nginx -s quit && sudo nginx

Checkout nginx guide

  • 1
    This does the job, but are you sure a proper shell script does not exist? This method is very raw.
    – asdmin
    Sep 2, 2016 at 15:11
  • 1
    At least, this is the official documentation. For sure, I will follow the hereby solution also. Thank you. Feb 6, 2019 at 9:55

Using MAMP and Nginx? Then you have an installed script:

sudo /Applications/MAMP/bin/restartNginx.sh 

Just another note, if you want to start nginx with launchctl, when your Mac boots up, you can do as follows:

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

In short, you need to put your plist file in /Library/LaunchDaemons, not in ~/Library/LaunchAgents like the Homebrew instructions. Finally, use the -w option with launchctl. For further information, follow this guide.


If you installed nginx with brew and you started it as a service brew services start nginx then you can issue: brew services restart nginx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.