"Too many open files" error

Hi,

I have had this error twice within +/- one month:
> Sep 30 15:16:52 nix dovecot: deliver(user@domain.com): open(/home/vmail/domain.com/user/maildirsize) failed: Too many open files

I need to restart dovecot and wait for the mailqueue to empty to make things work again.

Googling this error lead me to think I needed to increase the maximum open files, however, in a standard working situation, I am far from the limit:

# cat /proc/sys/fs/file-nr
1792    0   35041
# lsof -n | wc -l
3742

not sure why these figures are different, but anyhow, far from the 35041 files allowed.

proc(5) also lead me to cat /proc/sys/fs/inode-max but I have no such file on my linode (nor on my workstations).

I have asked to be moved to a newer host quite recently (now on newark157) as I had problems with 2.6.18 kernel and ntp. Not sure if this is related but I had never encountered such issues before.

I have no specific policy defined in /etc/security/limits.conf

Any idea?

Thanks in advance for your help!

Cheers,

Julien

9 Replies

Sounds like if it were hitting the system-wide limit found in /proc, you'd get a slightly different error message.

I'd suspect that there is a ulimit set for the user Dovecot is running as. Note that /etc/security/limits.conf isn't the only place to look, but I'll be damned if I can figure out where the limits are being set on my system (it's not /etc/profile).

Hi, thanks for your reply.

Unfortunately, this is not my issue:

dovecot@nix:~$ ulimit 
unlimited

I am reluctant to raise the maximum open files for the whole system as I only run a small server for 2 users (smtp/imap/http) hence I doubt I reach the limits set by Linode… even a Linode360.

Any other hints?

Cheers,

Julien

Try "ulimit -n". "ulimit" implies "-f" which is the maximum size of files written by the shell and its children; -n is the maximum number of open file descriptors.

You are right, I wasn't aware of this!

It gives

dovecot@nix$ ulimit -n
1024

It is the same for all other users I have tried.

Not sure where this limit comes from. A default kernel setting?

but again, in a "standard" situation (ie. when everything is working), I am far from this limit:

# lsof -nu dovecot | wc -l
87

One strange thing is that the apache user has 1502 open files, despite the limit set to 1024.

lsof also accounts for network files, which might not be taken into account in these limits.

Cheers,

Julien

ulimit is set per-account, so the user being used by apache may have a different limit set.

www-data (user running apache) also has a limit set to 1024.

As for my main issue, I think (though requires more testing) it was due to a bug in the development version of DSPAM, which left numerous open pipes.

Cheers,

Julien

What are the contents of /etc/security/limits.conf ?

Search /etc/* for "ulimit"

Hi,

/etc/security/limits.conf is empty (if I remove the default comments of course).

Nothing intersting in /etc :

# rgrep -i ulimit /etc/
logcheck/ignore.d.server/mldonkey-server:^\w{3} [ :0-9]{11} [._[:alnum:]-]+ mlnet_error: [/[:digit:]]{10} [:[:digit:]]{8} \[cO\] Language [[:upper:]]+, locale [-_.[:alnum:]]+, ulimit for open files [[:digit:]]+$
/etc/login.defs:#ULIMIT

Cheers,

Julien

@JulienV:

www-data (user running apache) also has a limit set to 1024.

Hum… I was not checking on the right server! Sorry for this.

And you are right, www-data has no limits ("unlimited").

Cheers,

Julien

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct