AnswerBun.com

nginx stop/reload on windows failed for Access is denied

Server Fault Asked by TN. on December 5, 2020

I am running nginx on Windows Server 2008 R2 (x64) as a windows service. I am using Windows Service Wrapper for that. (Actually, I have followed this tutorial: http://mercurial.selenic.com/wiki/HgServeNginxWindows.)

The service is running ok. However, the server does not process the signals (e.g. stop / reload).

This means if I stop the service, nginx is not stopped. (I have to kill it.)

And when I want to reload the configuration from command line:

C:UsersAdministrator>E:apathnginxnginx.exe -p E:apathnginx -c E:apathnginx.conf -s reload

It outputs:

nginx: [error] OpenEvent("Globalngx_reload_4268") failed (5: Access is denied)

I am running the command as administrator and the service is running under NETWORK SERVICE user.

Any hints or similar issues?

7 Answers

  1. Open cmd as Administrator.
  2. Then cd to the folder where nginx is located and then run the commands:

cmd (as Administrator)

cd E:apathnginxnginx.exe
start nginx

Answered by doset on December 5, 2020

Based on your output, I assume that you are on a Windows box. I encountered exactly the same problem. I solved my problem by finding out that the Nginx was managed by NSSM. I installed the Nginx via chocolatey and it treated NSSM as a dependency.

Launch an administrative Command Prompt and run the following.

nssm restart nginx

Answered by Lei Zhao on December 5, 2020

  1. Open cmd as Administrator.
  2. Then cd to the folder where nginx is located and then run the commands:

cmd (as Administrator)

cd E:apathnginxnginx.exe
nginx -s reload

Answered by Kent Pawar on December 5, 2020

You must run reload from the same account as service run. For example, if you run your nginx as SYSTEM, then you can use psexec tool:

PSEXEC -s c:nginxnginx.exe -p c:nginx -s reload

Answered by Yaroslav Sivakov on December 5, 2020

in order for it to work for me on Windows 10 with nginx 1.9.15 i had to add

-p c:nginx 

in the stop arguments

<service>
  <id>nginx</id>
  <name>nginx</name>
  <description>nginx</description>
  <executable>c:nginxnginx.exe</executable>
  <logpath>c:nginx</logpath>
  <logmode>roll</logmode>
  <depend></depend>
  <startargument>-p</startargument>
  <startargument>c:nginx</startargument>

  <stopexecutable>c:nginxnginx.exe</stopexecutable>
  <stopargument>-p</stopargument>
  <stopargument>c:nginx</stopargument>
  <stopargument>-s</stopargument>
  <stopargument>stop</stopargument>
</service>

Answered by Steven Kohlmeyer on December 5, 2020

I run my nginx-service under LOCAL SYSTEM and I use following xml configuration:

<service>
      <id>nginx-service</id>
      <name>nginx-service</name>
      <description>nginx-service</description>
      <executable>c:nginxnginx.exe</executable>
      <logpath>c:nginx</logpath>
      <logmode>roll</logmode>
      <depend></depend>
      <startargument>-pc:nginx</startargument>
      <stopexecutable>c:nginxnginx.exe</stopexecutable>
      <stopargument>-s</stopargument>
      <stopargument>stop</stopargument>
  </service>

I'm using Windows Service Wrapper 1.18 and this configuration works for me. Nginx processes should be stopped gracefully now. Good luck.

Answered by ssanchezz23 on December 5, 2020

A couple things to try:

  1. Why run in the NETWORK SERVICE account? Try with the default for all services, LocalSystem.

  2. Follow this tutorial to try another wrapper, AlwaysUp. If it works then you may be facing a problem with Windows Service Wrapper.

Please report what you find.

Answered by CoreTech on December 5, 2020

Add your own answers!

Related Questions

Rewrite with [P] flag lands in wrong vhost

0  Asked on November 24, 2021 by nthdegree

   

Delete files from rdiff-backup

3  Asked on November 22, 2021

 

How do I setup a SENT and TRASH folder with Dovecot?

3  Asked on November 22, 2021 by old-account

       

Resetting a queue discipline back to the default pfifo_fast one?

3  Asked on November 22, 2021 by francois-marier

   

Shibboleth does pass attribute to server variable in PHP

1  Asked on November 22, 2021 by pete-k

   

Use of CPUQuota in systemd

2  Asked on November 22, 2021 by stevegr2015

     

Using Cloudfront as a HAProxy backend server using https

2  Asked on November 22, 2021 by shubham-kanodia

     

Libruby.so library not in default library location

1  Asked on November 22, 2021 by kishore-kumar

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir