Dovecot Crashes Upon Restart

How the Issue Manifests

Dovecot crashes and will not fully restart.

Common Cause of the Issue

The internal memory settings for Dovecot are being reached when the service is active.

Troubleshooting

Check the Dovecot Log for Memory Errors

  1. Log in to the server at the CLI as root, either via SSH or from the terminal

  2. With a text editor, open /var/log/dovecot/dovecot.log. The following example uses the Vim text editor:

    vim /var/log/dovecot/dovecot.log
    
  3. Search the log for output similar to the following–this indicates that the internal memory settings for Dovecot are being reached and that is killing the service:

    Oct 01 20:25:27 config: Fatal: block_alloc(67108864): Out of memory
    Oct 01 20:25:27 config: Error: Raw backtrace: /usr/lib64/dovecot/libdovecot.so.0(backtrace_append+0x42) [0x7f79ca718582] -> /usr/lib64/dovecot/libdovecot.so.0(backtrace_get+0x1e) [0x7f79ca71868e] -> /usr/lib64/dovecot/libdovecot.so.0(+0xe5b5e) [0x7f79ca722b5e] -> /usr/lib64/dovecot/libdovecot.so.0(+0xe5c01) [0x7f79ca722c01] -> /usr/lib64/dovecot/libdovecot.so.0(i_error+0) [0x7f79ca67ec96] -> /usr/lib64/dovecot/libdovecot.so.0(+0x1077d6) [0x7f79ca7447d6] -> /usr/lib64/dovecot/libdovecot.so.0(+0x10782b) [0x7f79ca74482b] -> /usr/lib64/dovecot/libdovecot.so.0(+0x7a8d3) [0x7f79ca6b78d3] -> /usr/lib64/dovecot/libdovecot.so.0(+0x7a879) [0x7f79ca6b7879] -> /usr/lib64/dovecot/libdovecot.so.0(settings_parser_init_list+0x13f) [0x7f79ca6b7b6f] -> /usr/lib64/dovecot/libdovecot.so.0(settings_parser_init+0x1a) [0x7f79ca6b7c1a] -> dovecot/config(+0x126e6) [0x560b0f1f06e6] -> dovecot/config(config_parser_apply_line+0x538) [0x560b0f1f1508] -> dovecot/config(config_parse_file+0x8e7) [0x560b0f1f2297] -> dovecot/config(main+0xba) [0x560b0f1ec30a] -> /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f79ca291555] -> dovecot/config(+0xe39c) [0x560b0f1ec39c]
    Oct 01 20:25:27 master: Error: service(config): command startup failed, throttling for 60.000 secs
    Oct 01 20:25:27 config: Fatal: master: service(config): child 14958 returned error 83 (Out of memory (service config { vsz_limit=256 MB }, you may need to increase it) - set CORE_OUTOFMEM=1 environment to get core dump)
    Oct 01 20:25:27 stats: Fatal: Error reading configuration: read(/var/run/dovecot/config) failed: read(size=8192) failed: Connection reset by peer
    Oct 01 20:25:27 master: Error: service(stats): command startup failed, throttling for 60.000 secs
    Oct 01 20:25:27 master: Warning: Killed with signal 15 (by pid=13953 uid=0 code=kill)
    Oct 01 20:25:30 log(20795): Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
    

How to Resolve

  1. Log in to the server at the CLI as root, either via SSH or from the terminal

  2. At the CLI, navigate to /etc/dovecot/conf.d

  3. Using a text editor, create a new conf file named 99-vsz_limit.conf. The following example uses the Vim text editor:

    vim 99-vsz_limit.conf
    
  4. Add the following to the file, replacing {256M} (which is the default setting) with the desired limit

    Note

    The most common practice when raising a setting like this is to double it. So, for example, as the default is 256M, the next setting to try would be 512M. This may require some trial and error to identify the correct setting. If the error still occurs after raising to 512M and restarting or reloading Dovecot, trying again with 1024 may be needed, etc.

    default_vsz_limit = {256M}
    
  5. Save the file, and exit the text editor

  6. Restart or reload Dovecot

    systemctl restart dovecot
    

    or

    systemctl reload dovecot