Welcome to Centmin Mod Community
Register Now

Nginx Trouble restarting Nginx after last update ("Address already in use")

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by deltahf, Oct 12, 2016.

Tags:
  1. deltahf

    deltahf Premium Member Premium Member

    587
    265
    63
    Jun 8, 2014
    Ratings:
    +489
    Local Time:
    6:15 AM
    Since my last software update, I've had trouble restarting Nginx:

    Code:
    $ service nginx restart
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    Stopping nginx:                                            [  OK  ]
    Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
    nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
    nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
    nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
    nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
    nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
    nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
    nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
    nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
    nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
    nginx: [emerg] still could not bind()
                                                               [FAILED]
    To get it working again, I have to manually kill the processes:
    Code:
    $ fuser -k 80/tcp
    80/tcp:              29707
    $ fuser -k 443/tcp
    $ service nginx restart
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    Stopping nginx:                                            [FAILED]
    Starting nginx:                                            [  OK  ]
    
    I've never had this trouble before. Any way to fix this, or is something wrong?


    Centmin Mod 1.2.3-eva2000.08
    Nginx 1.11.4
    PHP 5.6.25
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,860
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    8:15 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    every time you restart nginx ?

    tried updating via centmin.sh menu option 23 submenu option 2, existing centmin.sh and re-enter centmin.sh directory and recompile centmin.sh menu option 4

    then if still an issue, to troubleshoot you need to check the the nginx upgrade log at /root/centminlogs and instructions under Sharing logs and errors heading for using Pastebin.com or Gists to share a sanitised version of the contents of the initial install log. You can see full details at How to troubleshoot Centmin Mod initial install issues

    also what's output of
    Code (Text):
    nginx -t

    when you run centmin.sh menu option 4 there's a nginx upgrade log timestamped at /root/centminlogs

    if you type this command it lists all logs in date ascending order so latest log at bottom
    Code (Text):
    ls -lArt /root/centminlogs

    so copy the entire contents of latest nginx_upgrade log to gist.github.com or pastebin.com

    you can use grep to filter the logs, i.e. look for nginx_upgrade in log name
    Code (Text):
    ls -lahrt /root/centminlogs/ | grep nginx_upgrade
    -rw-r--r--  1 root root 3.2M Oct 11 15:55 centminmod_1.2.3-eva2000.09.001_111016-155345_nginx_upgrade.log
    -rw-r--r--  1 root root 672K Oct 11 22:06 centminmod_1.2.3-eva2000.09.001_111016-220515_nginx_upgrade.log

    So the last nginx upgrade log was named centminmod_1.2.3-eva2000.09.001_111016-220515_nginx_upgrade.log and located at /root/centminlogs/centminmod_1.2.3-eva2000.09.001_111016-220515_nginx_upgrade.log
    then use cat command to output the contents of that log

    clear your ssh window buffer/screen and type
    Code (Text):
    cat /root/centminlogs/centminmod_1.2.3-eva2000.09.001_111016-220515_nginx_upgrade.log

    then select and copy and paste output to pastebin.com or gist.github.com file to share

    so only need content of one specific log, in this case most recent nginx_upgrade.log log
     
  3. deltahf

    deltahf Premium Member Premium Member

    587
    265
    63
    Jun 8, 2014
    Ratings:
    +489
    Local Time:
    6:15 AM
    Wow, you are scary fast, eva. :D

    This has happened to me 3 or 4 times now (every time since I did that update), but since I have posted this message... no more errors. o_O I guess you are just that good. :ROFLMAO:

    If it happens again I will run the checks above and let you know. (y)
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,860
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    8:15 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    hehe.. it can happen for busy nginx servers on restart as it takes time for threads to terminate it's work load especially if you have alot of nginx workers set for worker_processes in /usr/local/nginx/conf/nginx.conf. If you have alot of cpu threads on server, centmin mod might have set the value for worker_processes too high. You can try and see about just setting it lower i.e. if you have 8 cpu threads set worker_processes to 4.
     
  5. deltahf

    deltahf Premium Member Premium Member

    587
    265
    63
    Jun 8, 2014
    Ratings:
    +489
    Local Time:
    6:15 AM
    Ah, OK, interesting.

    It's a dedicated box with an E3-1230 v3 @ 3.30GHz (4 cores, 8 threads) and worker_processes is set to 8, so maybe I should adjust that a bit... I will set it to 4 now.
     
  6. Jon Snow

    Jon Snow Active Member

    840
    170
    43
    Jun 30, 2017
    Ratings:
    +257
    Local Time:
    7:15 AM
    Nginx 1.13.9
    MariaDB 10.1.31
    @eva2000 Got a similar error just now after creating a sub domain for a Lindoe server with 2 IPs.

    fuser isn't a command that's found.

    Code (Text):
    systemctl status nginx.service
    ● nginx.service - SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server
       Loaded: loaded (/etc/rc.d/init.d/nginx; bad; vendor preset: disabled)
       Active: failed (Result: exit-code) since Wed 2019-07-17 04:49:04 UTC; 6s ago
         Docs: man:systemd-sysv-generator(8)
      Process: 19700 ExecStart=/etc/rc.d/init.d/nginx start (code=exited, status=1/FAILURE)
     Main PID: 3060 (code=exited, status=0/SUCCESS)
    
    Jul 17 04:49:02 li12345.members.linode.com nginx[19700]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
    Jul 17 04:49:02 li12345.members.linode.com nginx[19700]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
    Jul 17 04:49:03 li12345.members.linode.com nginx[19700]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
    Jul 17 04:49:03 li12345.members.linode.com nginx[19700]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
    Jul 17 04:49:04 li12345.members.linode.com nginx[19700]: nginx: [emerg] still could not bind()
    Jul 17 04:49:04 li12345.members.linode.com nginx[19700]: [FAILED]
    Jul 17 04:49:04 li12345.members.linode.com systemd[1]: nginx.service: control process exited, code=exited status=1
    Jul 17 04:49:04 li12345.members.linode.com systemd[1]: Failed to start SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server.
    Jul 17 04:49:04 li12345.members.linode.com systemd[1]: Unit nginx.service entered failed state.
    Jul 17 04:49:04 li12345.members.linode.com systemd[1]: nginx.service failed.
     
  7. Jon Snow

    Jon Snow Active Member

    840
    170
    43
    Jun 30, 2017
    Ratings:
    +257
    Local Time:
    7:15 AM
    Nginx 1.13.9
    MariaDB 10.1.31
    OK my issue was configuring the right IP in the vhost config for the new sub domain I used.

    That solved my issue, in case anyone else runs into my issue.
     
  8. eva2000

    eva2000 Administrator Staff Member

    54,860
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    8:15 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Thanks for the update :)