I can't stop the nginx server on windows. I've tried: nginx -s stop
, taskkill /if nginx.exe
, and end process via task manager, yet it's still running!
8 Answers
Use @taskkill /f /im nginx.exe
for this task.
-
1
-
-
1@Normajean the
/f
switch does a force, which is sometimes needed. you might also need an elevated command prompt. otherwise, it is possible to sometimes get processes that cannot be killed. I'm not sure what causes it. I would also check that this isn't a service that needs stopping instead. Jan 10, 2020 at 11:26 -
Searching for 2 hour and just found the method to kill multiple process at once. +1. Nice & clean Sep 27, 2022 at 6:39
One can toggle Nginx start stop in Windows using 2 command prompts. One for Nginx start and other for Nginx Stop.
If you stop Nginx from one command prompt then the Nginx process which was started from other prompt will automatically stop, Otherwise if you try to stop the Nginx process from where it started using ctrl+c then it will not stop even tough you close the command prompt, Unless you kill the nginx processes from TaskManager.
Starting nginx with daemon off
will do the trick.
nginx is detauched from the console by default, independently if you run it directly using
./nginx.exe
or (as suggested by the guide) using
start ./nginx.exe
if you wanna stay coupled with the process who run the nginx (so it can pass the SIGTERM / CTRL+C to the nginx) you have to run this command:
nginx -g "daemon off;"
Make a .bat file in the nginx.exe folder with the command: nginx.exe -s quit
. Then make a shortcut to desktop or whereever needed.
We can follow the steps motioned below to quit or reload the nginx if facing any issue like.
nginx: [error] CreateFile() "...logs/nginx.pid" failed
(2: The system cannot find the file specified)
Make a windows shortcut somewhere and add the following in the target box:
C:\Windows\System32\cmd.exe /k "wmic process where name='nginx.exe' delete" && exit
Anytime you double clicked, nginx get shut down.