I‘ve Squid Proxy server with over 100 Windows workstation. I see following error message in my cache.log file:

WARNING! Your cache is running out of filedescriptors

Do I need to filter proxy server requests to avoid this problem? How do I fix this problem under CentOS / Fedora / RHEL / Debian Linux?

If you see this message in your /var/log/squid/cache.log file, it means Squid proxy server is running out of file descriptors and cannot handle the extra requests sent by your client computers.

Task: Find out current file descriptors limits

Login to your Squid proxy server and type the following command at shell prompt:
# squidclient mgr:info | grep 'file descri'
# squidclient -p {port} -u {proxy-user} -w '{proxy-password}' mgr:info | grep 'file descri'
# squidclient -p 8080 -u admin -w 'secretePassword' mgr:info | grep 'file descri'

Sample output:

        Maximum number of file descriptors:   1024
        Available number of file descriptors: 1008
        Reserved number of file descriptors:   100

Squid increase the maximum file descriptors

First, update /etc/security/limits.conf file:
# vi /etc/security/limits.conf
Append following line to increase current limit from 1024 to 4096:
* - nofile 4096
Save and close the file. You must re-login to check new limits:
# ulimit -a | grep ‘open files’
Sample output:

open files                      (-n) 4096

Next you need to set the maximum number of open file descriptors by modifying squid proxy server configuration as per your Linux distribution.

Set max_filedesc under RHEL / Red Hat / CentOS / Fedora Linux

Stop the Squid as changes of this value isn’t respected by reconfigure command. This value should be changed only if there isn’t any active squid process.
# service squid stop
Open /etc/squid/squid.conf file
# vi /etc/squid/squid.conf
Append / add / modify max_filedesc directive:
max_filedesc 4096
Save and close the file. Start the squid proxy server:
# service squid start
Now again run squidclient command or check log files for messages:
# squidclient mgr:info

Set max_filedesc under Ubuntu / Debian Linux

First, stop squid proxy server, enter:
# /etc/init.d/squid stop
$ sudo /etc/init.d/squid stop
Open /etc/default/squid to set max. number of filedescriptors to use. You can increase this on a busy
cache to a maximum of (currently) 4096 filedescriptors. Default is 1024.
$ sudo vi /etc/default/squid
# vi /etc/default/squid
Save and close the file. Start the squid proxy server:
$ sudo /etc/init.d/squid start
Verify that it is working with new limits:
# squidclient mgr:info | grep 'file descri'

See also:

  1. FreeBSD Squid Proxy Caching Server Increase File Descriptors Limits

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 11 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
11 comments… add one
  • Balaviswanathan Oct 12, 2008 @ 18:00

    This article is very useful to me . Thanks for the update

  • Julio Apr 1, 2009 @ 18:55

    There is a typo were it says:
    Stop the Squid as changes of this value isn’t respected by reconfigure command. …
    # service squid start

    The correct is:
    # service squid stop

  • 🐧 nixCraft Apr 1, 2009 @ 19:15

    Thanks for the heads up.

  • rafee Jun 20, 2009 @ 16:21

    how to configure proxy server?

  • hungnv Dec 18, 2009 @ 10:23

    Why you choose 4096? How can I calculate which number is good for me?

  • rafha Mar 6, 2012 @ 17:40

    nice.. but not work in squid 3.0 stable xx

  • Zaman Oct 4, 2013 @ 9:44

    I have the error message in my log file:
    “Your cache is running out of filedescriptors”
    Solution is:
    visible_hostname directive is missing

  • okwap Mar 19, 2014 @ 6:49

    In my ubuntu 10.04, I should use RHEL / Red Hat / CentOS / Fedora way to take the effect

  • khandu Jul 3, 2014 @ 6:36

    i have same problem Your cache is running out of file descripters

    please tell solution

  • Greg Jan 11, 2016 @ 12:43

    I have Changed my max_filedesc value to 51200 but whenever my machine starts, the value is reverting to 1024. However, when I do service squid restart, it picks the value specified in the /etc/squid/squid.conf file which is 51200. What might be causing this?

  • HellofromRussia Feb 13, 2016 @ 20:32

    Thanks !!!

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum