Bug 1309539

Summary: Nginx will fail to start if /var/run/nginx.sock already exists
Product: [Fedora] Fedora EPEL Reporter: Horace <bugs.management>
Component: nginxAssignee: Nobody's working on this, feel free to take it <nobody>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: epel7CC: affix, athmanem, bperkins, jeremy, jkaluza, pavel.lisy, wtogami
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-06-05 17:37:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Horace 2016-02-18 04:45:27 UTC
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. yum install -y nginx
2. systemctl start nginx
3. systemctl restart nginx

Actual results:
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl 
-xe" for details.

* nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2016-02-17 23:21:07 EST; 7s ago
  Process: 28866 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE)
  Process: 28863 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 28860 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 591 (code=exited, status=0/SUCCESS)

Feb 17 23:21:05 mx nginx[28866]: nginx: [emerg] bind() to unix:/var/run/nginx.sock failed (98: Address already in use)
Feb 17 23:21:05 mx nginx[28866]: nginx: [emerg] bind() to unix:/var/run/nginx.sock failed (98: Address already in use)
Feb 17 23:21:06 mx nginx[28866]: nginx: [emerg] bind() to unix:/var/run/nginx.sock failed (98: Address already in use)
Feb 17 23:21:06 mx nginx[28866]: nginx: [emerg] bind() to unix:/var/run/nginx.sock failed (98: Address already in use)
Feb 17 23:21:07 mx nginx[28866]: nginx: [emerg] bind() to unix:/var/run/nginx.sock failed (98: Address already in use)
Feb 17 23:21:07 mx nginx[28866]: nginx: [emerg] still could not bind()
Feb 17 23:21:07 mx systemd[1]: nginx.service: control process exited, code=exited status=1
Feb 17 23:21:07 mx systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Feb 17 23:21:07 mx systemd[1]: Unit nginx.service entered failed state.
Feb 17 23:21:07 mx systemd[1]: nginx.service failed.



Expected results:

Restart successfully

Additional info:

Version     : 1.6.3
Release     : 8.el7

Comment 1 Horace 2016-02-18 04:48:47 UTC
Additionally, the current fix is to copy /usr/lib/systemd/system/nginx.service to /etc/systemd/system/nginx.service and add ExecStartPre=/usr/bin/rm -f /var/run/nginx.sock to the service file.

Comment 2 Jamie Nguyen 2016-06-05 17:37:57 UTC
Hi Horace. Thanks for your report. /var/run/nginx.sock isn't used in the default configuration.