当前位置:   article > 正文

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

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

1. 错误描述

通过nginx负载两个节点的rabbitmq
当用java代码创建超过500个连接时(我的机器默认只能创建这么多),出现错误:

com.rabbitmq.client.ShutdownSignalException: connection error
java.net.SocketException: Software caused connection abort: recv failed
  • 1
  • 2

查看nginx日志/var/log/nginx/error.log,发现错误
socket() failed (24: Too many open files) while connecting to upstream

解决

  1. 修改linux打开文件句柄数,编辑vi /etc/security/limits.conf,添加
<domain>      <type>  <item>         <value>
*             soft   nofile          204800
*             hard   nofile          204800
  • 1
  • 2
  • 3
  1. 修改nginx打开文件数, 编辑nginx.conf,添加worker_rlimit_nofile值
worker_processes  1;
worker_rlimit_nofile 20480;
  • 1
  • 2

重启nginx后问题解决

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/660222
推荐阅读
相关标签
  

闽ICP备14008679号