nginx报错:socket() failed (24: Too many open files) while connecting to upstream

文章
nginx报错:socket() failed (24: Too many open files) while connecting to upstream-下一朵云

nginx反代新项目,在线人数过多时就会报错,查看日志,报错如下:

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

解决办法

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

*             soft   nofile          204800
*             hard   nofile          204800

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

worker_processes  1;
 worker_rlimit_nofile 20480;

3.重启nginx后解决

./nginx -s stop 
./nginx