node and Error: EMFILE, too many open files

前端 未结 18 1770
终归单人心
终归单人心 2020-11-28 17:58

For some days I have searched for a working solution to an error

Error: EMFILE, too many open files

It seems that many people have the same proble

18条回答
  •  时光取名叫无心
    2020-11-28 18:21

    I did all the stuff above mentioned for same problem but nothing worked. I tried below it worked 100%. Simple config changes.

    Option 1 set limit (It won't work most of the time)

    user@ubuntu:~$ ulimit -n 65535
    

    check available limit

    user@ubuntu:~$ ulimit -n
    1024
    

    Option 2 To increase the available limit to say 65535

    user@ubuntu:~$ sudo nano /etc/sysctl.conf
    

    add the following line to it

    fs.file-max = 65535
    

    run this to refresh with new config

    user@ubuntu:~$ sudo sysctl -p
    

    edit the following file

    user@ubuntu:~$ sudo vim /etc/security/limits.conf
    

    add following lines to it

    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
    

    Option 3 Just add below line in

    DefaultLimitNOFILE=65535
    

    to /etc/systemd/system.conf and /etc/systemd/user.conf

提交回复
热议问题