LoginSignup
10
5

More than 3 years have passed since last update.

dialing failed socket: too many open files

Last updated at Posted at 2019-11-05

概要

ubuntu18.04にて、golangのアプリケーションを動かしていた際に、発生したエラー。
「Too many open files」は Linux でプロセスが開けるファイルディスクリプタの上限に達してしまうと発生するエラーです。

[HTTP] http: Accept error: accept tcp [::]:80: accept4: too many open files; retrying in 1s

解決策

# edit the following file
user@ubuntu:~$ sudo vim /etc/security/limits.conf

# add following lines to it
* soft     nproc          65535    
* hard     nproc          65535   
* soft     nofile         65535   
* hard     nofile         65535
root soft     nproc          65535    
root hard     nproc          65535   
root soft     nofile         65535   
root hard     nofile         65535

# edit the following file
user@ubuntu:~$ sudo vim /etc/pam.d/common-session

# add this line to it
session required pam_limits.so

# logout and login and try the following command
user@ubuntu:~$ ulimit -n
65535

参考

別の解決策

systemdで設定をする。

[Service]
LimitNOFILE=65535
systemctl daemon-reload
systemctl restart <your deamon>
grep "open files" /proc/`pidof <your deamon>`/limits

参考

10
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
5