Want to subscribe to topics you're interested in?
Become a Member

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 Active Member

    216
    104
    43
    Jun 8, 2014
    Ratings:
    +161
    Local Time:
    2:51 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

    30,842
    6,903
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,393
    Local Time:
    5:51 PM
    Nginx 1.13.x
    MariaDB 5.5
    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
     
    • Useful Useful x 1
  3. deltahf

    deltahf Active Member

    216
    104
    43
    Jun 8, 2014
    Ratings:
    +161
    Local Time:
    2:51 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

    30,842
    6,903
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,393
    Local Time:
    5:51 PM
    Nginx 1.13.x
    MariaDB 5.5
    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.
     
    • Informative Informative x 1
  5. deltahf

    deltahf Active Member

    216
    104
    43
    Jun 8, 2014
    Ratings:
    +161
    Local Time:
    2:51 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.