Squid: WARNING! Your cache is running out of filedescriptors
So you have a LAN with 50+ users and you set up a nice Squid w3cache as a transparent proxy with 100GB of space reserved for the cache (hdds are so cheap nowadays…). Weeks pass and suddenly you notice that something is messing up your web experience as Firefox suddenly decides to run painfully slow. About 30 minutes wasted on finding the culprit (like changing your DNS servers, clearing browser cache, etc.) until you decide to check the router and then the Squid with its logs. And then you find something fishy:
2007/01/01 17:51:19| WARNING! Your cache is running out of filedescriptors 2007/01/01 17:51:35| WARNING! Your cache is running out of filedescriptors 2007/01/01 17:51:51| WARNING! Your cache is running out of filedescriptors (...)
I won’t be explaining why this happens. Others have done it before. What I’m going to do is present you with a solution that does not require a complete Squid recompilation/reinstallation procedure.
RedHat/Fedora
/etc/init.d/squid stop nano /etc/squid/squid.conf max_filedesc 4096 nano /etc/init.d/squid # add this just after the comments (before any script code) ulimit -HSn 4096 /etc/init.d/squid start
Debian
nano /etc/defaults/squid SQUID_MAXFD=4096 /etc/init.d/squid restart
Ubuntu
nano /etc/default/squid SQUID_MAXFD=4096 /etc/init.d/squid restart
And now watch the /var/log/squid/cache.log for a similar line:
2007/01/01 18:32:27 With 4096 file descriptors available
If it still says 1024 file descriptors available (or similarly low value) you are out of luck (or you’ve just messed something up).

April 16th, 2007 at 2:49 pm
Surely the editing of /usr/include/bits/typesizes.h is unnecessary if you don’t recompile Squid (and anyway, that version of Squid doesn’t need to have that file changes anyway, as its configure script has a –maxfd option).
I was certainly able to up my FC6’s squid installation to use 2048 descriptors by changing just /etc/init.d/squid and /etc/squid/squid.conf
November 29th, 2007 at 9:12 am
On Debian you can increase the number of fds by changing /etc/defaults/squid.
January 3rd, 2008 at 1:26 pm
Thanks a bunch. Using /etc/defaults/squid in Squid is the most trivial place to find but somehow I looked in the wrong places. Pushing that from 1024 to 4096 instantly got my users happy.
January 4th, 2008 at 1:20 pm
Thanks for the tips! I’ve updated the article.
January 30th, 2008 at 12:29 pm
Thank’s guys. This is great … (I’ve had exactly the same problem, but resolved). Again thank’s …
March 15th, 2008 at 5:39 am
Thanks mate. I was guessing for the worse, like someone is ddos-ing my squid.
March 17th, 2008 at 10:56 am
Thanks alot. It helped me in IPCOP.
I used this command : SQUID_MAXFD=4096
while squid was stopped and then I started the squid and it works fine now.
Thanks a bunch again. Keep it Up Please.
March 25th, 2008 at 6:54 pm
Omygosh, thank you, thank you, thank you, this saved me and my users so much heartache!
Slight typo in the Debian instructions, the squid restart command should read:
/etc/init.d/squid restart
March 25th, 2008 at 7:09 pm
Fixed! Thanks
September 6th, 2008 at 9:52 am
thanks man !!! save a lot of time