If Roundcube webmail is stuck at the "Logging you in…" screen, taking 30+ seconds to load, or throwing connection errors, the problem is almost always server-side — not the browser. As a cPanel/WHM server administrator, you have direct access to every layer that affects Roundcube performance: PHP-FPM, Dovecot, MySQL, and the mail index files. This guide walks you through every fix, from the quickest one-liners to the deeper Dovecot tuning that most guides skip.
Why Roundcube Loads Slowly in cPanel
Roundcube is a PHP application that talks to Dovecot via IMAP, stores session data in MySQL, and generates its interface through the web server. A slowdown anywhere in that chain will make webmail crawl or hang. The most common culprits are:
- PHP-FPM enabled for cPanel Daemons (a known cPanel configuration issue)
- Dovecot authentication process memory limit set too low
- Corrupt Dovecot index files on a mailbox with thousands of messages
- MySQL slow queries on the Roundcube
roundcubedatabase - Server RAM exhausted — Dovecot IMAP connections queue up waiting for memory
- Large inboxes with no full-text search (FTS) index causing search timeouts
💡 None of these worked? Skip the guesswork.
Get Expert Help →Step 1: Check Server Load and Memory First
Before diving into application-level fixes, confirm whether this is a resource problem:
top -bn1 | head -20
free -m
df -h /
If load average exceeds the number of CPU cores, or free memory is under 100 MB, address resource exhaustion before anything else. On a WHM server with many cPanel accounts, memory pressure is the single fastest path to sluggish webmail.
Roundcube logs errors to its own log file. On cPanel servers the path is:
tail -100 /var/cpanel/roundcube/log/errors
tail -100 /var/cpanel/roundcube/log/sendmail
Look for lines containing IMAP Error, Connection timed out, Login failed, or MySQL server has gone away. Each error type points to a different fix below.
Log in to WHM → search for MultiPHP Manager → click the PHP-FPM tab at the top. Look for an entry called cPanel Daemons or _cpanel.
If PHP-FPM is enabled for the internal cPanel services entry, disable it. Roundcube and other cPanel daemons (Horde, cPanel UI itself) run better under the default PHP handler, not PHP-FPM's per-request process model, which introduces connection overhead on each page load.
/scripts/restartsrv_httpd
Test Roundcube immediately. This single change resolves the slow-loading issue for the majority of cPanel servers running WHM 110 or later.
WHM → Mailserver Configuration → scroll to Process Memory Limit for Authentication → change from 128 to 256 (or higher on servers with ≥8 GB RAM) → click Save. WHM will update /var/cpanel/conf/dovecot/main and restart Dovecot automatically.
grep login_process_size /var/cpanel/conf/dovecot/main
# Should show: login_process_size = 256
/scripts/restartsrv_dovecot
The Roundcube error log will show the email address or username. Navigate to the mailbox path:
ls -lah /home/USERNAME/mail/DOMAIN/EMAILACCOUNT/
cd /home/USERNAME/mail/DOMAIN/EMAILACCOUNT/
mv dovecot.index dovecot.index.bak
mv dovecot.index.cache dovecot.index.cache.bak
mv dovecot.index.log dovecot.index.log.bak 2>/dev/null
Dovecot will automatically rebuild these files the next time the mailbox is opened. The rebuild takes a few seconds on large inboxes.
If the issue affects multiple accounts, use:
doveadm force-resync -u user@domain.com INBOX
# Or for all mailboxes on the server:
doveadm force-resync -A INBOX
mysql -u root roundcube -e "
SELECT table_name, ROUND((data_length+index_length)/1024/1024,2) AS size_mb
FROM information_schema.tables
WHERE table_schema='roundcube'
ORDER BY size_mb DESC;"
mysql -u root roundcube -e "TRUNCATE TABLE cache;"
mysql -u root roundcube -e "TRUNCATE TABLE cache_messages;"
mysql -u root roundcube -e "TRUNCATE TABLE cache_index;"
mysql -u root roundcube -e "TRUNCATE TABLE cache_thread;"
mysql -u root roundcube -e "OPTIMIZE TABLE cache, cache_messages, cache_index, cache_thread, session;"
This reclaims disk space and rebuilds indexes, which significantly speeds up session lookups during login.
du -sh /home/USERNAME/mail/DOMAIN/EMAILACCOUNT/
If the inbox is over 2 GB, Dovecot may time out while building the index for the initial folder listing. Advise the user to archive old emails via an IMAP client (Thunderbird, Outlook) and reduce the inbox to under 1 GB.
mysql -u root roundcube -e "DELETE FROM session WHERE ip='USER_IP_OR_USER_AGENT';"
# Or delete all sessions older than 1 day:
mysql -u root roundcube -e "DELETE FROM session WHERE changed < DATE_SUB(NOW(), INTERVAL 1 DAY);"
Edit /etc/dovecot/conf.d/20-imap.conf (or the equivalent WHM-managed path) and add:
imap_idle_notify_interval = 2 mins
mail_max_lock_timeout = 0
imap_fetch_failure = disconnect-immediately
Then restart Dovecot: /scripts/restartsrv_dovecot
find /usr/local/cpanel -name "php.ini" | xargs grep -l "memory_limit" 2>/dev/null | head -5
WHM → MultiPHP INI Editor → select the PHP version used by cPanel Daemons → increase memory_limit to 256M and max_execution_time to 120.
/scripts/restartsrv_httpd
Step 8: Check and Restart Dovecot and Exim Services
Sometimes the simplest fix is a service restart. Roundcube depends on Dovecot for IMAP and Exim for outgoing mail. If either has a hung process, webmail will stall.
# Check current status
/scripts/restartsrv_dovecot --check
/scripts/restartsrv_exim --check
# Restart both
/scripts/restartsrv_dovecot
/scripts/restartsrv_exim
# Verify they're listening on the right ports
ss -tlnp | grep -E '143|993|25|587'
Preventive Measures for Long-Term Roundcube Performance
- Set per-account mailbox quotas — keep individual mailboxes under 2 GB via cPanel → Email Accounts → Manage → Quota
- Schedule Roundcube DB cleanup — add a daily cron to purge old sessions:
mysql -u root roundcube -e "DELETE FROM session WHERE changed < DATE_SUB(NOW(), INTERVAL 7 DAY);" - Monitor Dovecot process count — add a check to WHM's Server Status or use
ps aux | grep dovecot | wc -lto catch runaway processes early - Keep Roundcube updated — WHM → Update Roundcube (or via
/scripts/update_roundcube) fixes known performance regressions - Enable Dovecot full-text search (FTS) — for servers with large mailboxes, FTS dramatically reduces search timeouts; configure via
/etc/dovecot/conf.d/90-plugin.conf
If Roundcube is consistently slow across all accounts despite these fixes, the root cause is usually under-provisioned server hardware. A cPanel/WHM server handling 50+ accounts needs at least 4 GB RAM and a modern SSD. If you're managing multiple cPanel servers and need expert hands to tune mail performance, CloudHouse's managed server support team can audit and optimise your entire stack — from Dovecot tuning to PHP-FPM configuration.
