# [Solved] how to set ulimit for dovecot service

## doublehelix

How do I set the ulimit for the service dovecot? Not for the whole system, just for dovecot.

Just for reference, this is required because I want to have 

```
client_limit=5000
```

 in dovecot's auth configuration.

Dovecot justifiably moans about the low ulimit:

 *Quote:*   

> warning: fd limit (ulimit -n) is lower than required under max. load (1024 < 5000), because of service auth { client_limit }

 Last edited by doublehelix on Sun Apr 07, 2019 9:16 pm; edited 1 time in total

----------

## pjp

I'd probably create a file for devecot in /etc/security/limits.d/ (man limits.conf for details). Something like "dovecot hard nofile 5000".

----------

## doublehelix

This seems like the correct solution. Unfortunately I can't get it to work. I still get the same warning on restarting dovecot.

I tried:

```

dovecot         soft    nofile      5000

dovecot         hard    nofile      5000

```

And since some of dovecot's processes run as root (and some as dovecot) I also added

```

root         soft    nofile      5000

root         hard    nofile      5000

```

And when that didn't work I tried (just for testing):

```

*         soft    nofile      5000

*         hard    nofile      5000

```

However there's still the same warning on service restart:

```

warning: fd limit (ulimit -n) is lower than required under max. load (1024 < 5000), because of service auth { client_limit }

```

It seems these settings are somehow not applied.

I've tried these in the self-created /etc/security/limits.d/dovecot and also in the existing /etc/security/limits.conf.

----------

## mike155

1) Do you use OpenRC? Or Systemd?

2) How do you start dovecot? From a 'root' login? Or during boot process?

Please note that /etc/security/limits.conf is provided by PAM. If PAM is not involved in the dovecot startup process, settings in /limits.conf won't be used... 

For example, if you use OpenRC and start dovecot during the boot process, settings in limits.conf won't be used, because there's no login. And if you log in as root and start dovecot manually, changes in limits.conf will only be used after you logged out and logged in again...

So yes, there's a lot of confusion about limits.conf. It doesn't work the way people think it should work.

----------

## doublehelix

I use OpenRC and start dovecot during boot (and manually after an upgrade) via 

```
/etc/init.d/dovecot start
```

So yeah, that explains the problem!

I found the OpenRC way to do it and it works!   :Very Happy: 

Create /etc/conf.d/dovecot with this content:

```
rc_ulimit="-n 5000"
```

----------

