Overview
Users may encounter an IMAP internal error when attempting to access webmail. This issue typically occurs when the Dovecot dovecot.index.cache file for a specific mailbox exceeds the default virtual memory size limit (vsz_limit) configured for the IMAP service. The following guide outlines how to identify affected mailboxes and adjust the configuration to resolve the out-of-memory error.
Symptoms
When logging into webmail, users receive the following error message:
IMAP error reported by server
INTERNAL ERROR
Could not load message from server
Concurrently, the system log at /var/log/maillog records an out-of-memory fatal error for the Dovecot IMAP service:
Feb 10 06:41:40 www0 dovecot: service=imap, user=user@example.com, ip=[203.0.113.1]. Fatal: master: service(imap): child 10671 returned error 83 (Out of memory (service imap { vsz_limit=512 MB }, you may need to increase it) - set CORE_OUTOFMEM=1 environment to get core dump)
Diagnosis
The default vsz_limit for the IMAP service is set to 512 MB. If a user's index cache file exceeds this threshold, the IMAP process terminates with error code 83. In some cases, files such as /var/qmail/mailnames/example.com/user/Maildir/dovecot.index.cache may grow significantly beyond this limit.
To identify mailboxes with oversized cache files, execute the following command:
find /var/qmail/mailnames/ -type f -name dovecot.index.cache -exec ls -al {} \; | sort -k 5 -n
This command lists all dovecot.index.cache files sorted by size in ascending order. Record the largest file size to determine the appropriate new memory limit.
Resolution
- Create or edit the custom configuration file at /etc/dovecot/conf.d/zzz_custom.conf.
- Add the service imap block and set the vsz_limit parameter to a value higher than the largest cache file identified during diagnosis. For example:
service imap {
vsz_limit = 1024MB
}
- Save the configuration file.
- Restart the Dovecot service to apply the changes:
systemctl restart dovecot
Troubleshooting & Common Issues
- Configuration Syntax Errors: Ensure proper indentation and syntax within /etc/dovecot/conf.d/zzz_custom.conf. Incorrect formatting may prevent Dovecot from starting. Verify the configuration using standard Dovecot validation commands before restarting if issues persist.
- Persistent Memory Limits: If users continue to experience out-of-memory errors after increasing the limit, monitor mailbox growth and consider implementing automated cache maintenance or storage quota policies.
- Service Restart Failures: Confirm that no other Dovecot configuration files conflict with the custom settings. Check system logs for additional error details if the service fails to start successfully.