I am running Squid 2.7 on Ubuntu 10.04 64bits. I had the problem of Squid running out of file descriptors, with the following error showing in /var/log/squid/cache.log:

WARNING! Your cache is running out of filedescriptors

I checked with:

squidclient mgr:info | grep 'file descri'

and it showed that I had only 1024 file descriptors available.

I changed /etc/security/limits.conf, adding this at the end:

* soft nofile 32768
* hard nofile 32768
proxy           soft    nofile          32768
proxy           hard    nofile          32768

Added this to /etc/squid/squid.conf:

max_filedescriptors 32768

Also changed /etc/default/squid:


Nothing was working out. In the end I edited /etc/init.d/squid to add "ulimit -n 32768":

#!/bin/sh -e
# upstart-job
# Symlink target for initscripts that have been converted to Upstart.

set -e
ulimit -n 32768
<... snipped  ...>

That worked! :)

I had to do all this under the stress of a live, production Squid server being incredibly slow, so I am sure that this is NOT the right way to do it.

But what is the right way to do it?


You have to add the ulimit line in the squid init script as well as increase max_filedescriptors in squid.conf. Those are the two essential steps. You no longer have to compile squid from source to increase this limit. That was something you had to do with really old squid versions.

  • rather than adding the ulimit line in /etc/init.d, could you not add it to /etc/security/limits.conf? – Cian Oct 28 '10 at 8:55
  • The changes in limits.conf seemed necessary in my experience. The ulimit line in /etc/init.d didn't work without the changes in limits.conf. – UrkoM Oct 28 '10 at 9:26

I had the same problem before. I was not able to increase the number of file descriptors of quid.

In addition to what you have done, I configured squid using the following configure options:

./configure --prefix=/usr/local/squid --enable-start-stop-daemon --with-filedescriptors=65536 --enable-storeio=ufs,aufs --with-aufs-threads=10

The important part for case is:


After doing this and restarting squid, I got the maximum value of file descriptors: 65536.

Of course, this requires squid to be installed from source not from the command:

apt-get install squid
  • I got it to have 32768 file descriptors already, without recompiling, so I agree with the answer above: this is not needed anymore. – UrkoM Oct 28 '10 at 9:25

/etc/init.d/squid is a symlink to /lib/init/upstart-job, so your original suggestion raises the ulimit for all upstart services.

I agree that the original question/solution raises the file descriptor limit, so thanks for that. Ideally a solution that didn't raise file descriptors across the board would be nicer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.