failed (24: Too many open files) while connecting to upstream, client:

查看nginx日志/var/log/nginx/error.log,发现错误

failed (24: Too many open files) while connecting to upstream

2021/06/28 14:18:09 [alert] 6672#0: *18115339 socket( ) failed (24: Too many open files) while connecting to upstream, client: 112.135.41.158, server: acs.peotv.com, request: "POST /acs HTTP/1.1", upstream: "http://172.17.225.41:8080/acs", host: "acs.peotv.com:443"

查看nginx日志,出现open files 的限制,意味着nginx上面的进程连接数不够导致的,于是在nginx配置中增加最大打开的进程数,文件句柄数等

查看文件句柄数(最大打开文件数): #ulimit -a : open files 默认1024
可修改默认设置: # ulimit -n 204800 最大值为655350

解决办法:

修改linux打开文件句柄数,编辑vi /etc/security/limits.conf,添加

  •         soft   nofile          204800
    
  •         hard   nofile          204800
    

修改nginx打开文件数, 编辑nginx.conf,添加worker_rlimit_nofile值

worker_rlimit_nofile 20480;

重启nginx后问题修复完成

创作者:吴仔汕
欢迎大家参考,还可以提出疑问或者不同看法噢。
原创作品,转载请标明出处!!

猜你喜欢

转载自blog.csdn.net/Zisson_no_error/article/details/119796198