# Roundcube Database Error and Login Loops: 4 cPanel Fixes

Source: https://srvscripts.com/guides/roundcube-database-error-login-loop/
Updated: 2026-10-03
Publisher: srvScripts (https://srvscripts.com/)

Roundcube on cPanel is updated as part of the normal `upcp` run (1.6.15 shipped with 136 and 1.6.19 with 138), and most of the time the schema migration it needs runs silently. When it does not, or when the underlying database is unhealthy, users get either a bare “DATABASE ERROR: CONNECTION FAILED” page or a login form that accepts the password and then shows itself again. Both are server-side problems, both are quick to fix once you know which back end the server uses, and neither is caused by the user’s password.

In short: Check roundcube_db in /var/cpanel/cpanel.config to see whether Roundcube uses MySQL or SQLite, then run /usr/local/cpanel/bin/update-roundcube –force, which recreates the database, user, schema and config for the MySQL back end and fixes…

**Short answer:** Check `roundcube_db` in `/var/cpanel/cpanel.config` to see whether Roundcube uses MySQL or SQLite, then run `/usr/local/cpanel/bin/update-roundcube --force`, which recreates the database, user, schema and config for the MySQL back end and fixes most DATABASE ERROR pages. For SQLite, fix ownership of the user’s `.rcube.db` file or free disk and quota space; a login loop that persists is a session-storage problem, so repair the `session` table or the temp directory and test directly against port 2096 to rule out a proxy.

## Identify the Roundcube back end

cPanel supports two storage modes for Roundcube’s own data (contacts, preferences, sessions, identities): a single MySQL database called `roundcube`, or one SQLite file per mail account under the user’s home. Check which is in use:

```
grep -E 'roundcube_db' /var/cpanel/cpanel.config
ls /home/*/etc/*/*.rcube.db 2>/dev/null | head -3
```

`roundcube_db=mysql` means the shared database. `roundcube_db=sqlite` means per-user files named `USER@DOMAIN.rcube.db`. The failures and the fixes differ by mode, so establish this first. The setting itself is under **WHM » Server Configuration » Tweak Settings » Mail » Roundcube database**.

## DATABASE ERROR with the MySQL back end

The message means Roundcube could not open its MySQL connection. The credentials are in `/usr/local/cpanel/base/3rdparty/roundcube/config/config.inc.php` in the `$config['db_dsnw']` line. Check each part in turn:

```
systemctl status mariadb
mysql -e "SHOW DATABASES LIKE 'roundcube'"
mysql roundcube -e "SHOW TABLES" | head
```

If MariaDB is down, fix that first; the [MariaDB startup guide](/guides/mariadb-not-starting-after-upgrade/) covers it. If the database is missing or the `roundcube` MySQL user cannot connect, let cPanel recreate it:

```
/usr/local/cpanel/bin/update-roundcube --force
```

That script recreates the database and user if needed, applies any pending schema updates, and rewrites the config with fresh credentials. It is safe to run on a live server and is the single most useful command for Roundcube trouble.

If the tables exist but the error page shows a query failure rather than a connection failure, a table is usually crashed or the schema is behind the code version:

```
mysqlcheck --auto-repair roundcube
mysql roundcube -e "SELECT name, value FROM system"
```

The `system` table holds `roundcube-version`. If it is lower than the version in `/usr/local/cpanel/base/3rdparty/roundcube/program/include/iniset.php`, the migration did not run; `update-roundcube --force` applies it. If MariaDB is refusing connections outright, check for the connection-limit case described in [fixing MySQL too many connections](/guides/fix-mysql-too-many-connections-cpanel/).

## DATABASE ERROR with the SQLite back end

Here the database is a file owned by the mail account’s user and the failure is nearly always ownership, permissions or a full disk:

```
ls -la /home/USER/etc/example.com/
df -h /home
```

The `.rcube.db` file must be owned by the cPanel user and writable by it, and the directory it lives in must be writable so SQLite can create its journal. Fix ownership with `chown USER:USER /home/USER/etc/example.com/*.rcube.db`. If the file is zero bytes or corrupt (the log says `file is not a database`), move it aside and Roundcube will create a fresh one on the next login; the user loses contacts and preferences but mail is untouched, because mail lives in Dovecot, not Roundcube.

A quota at 100% produces the same error because SQLite cannot write. Check with `quota -u USER` and see our [quota guide](/guides/cpanel-quotas-unlimited-fixquotas/) if the numbers look wrong.

## The login loop

When the form reloads with no message, Roundcube authenticated against Dovecot successfully and then failed to store the session. Causes, in order of likelihood:

- **Session storage broken**: with MySQL, the `session` table is crashed or full; with SQLite, the same permission issues as above. `mysqlcheck --auto-repair roundcube` or the ownership fix resolves it.

- **PHP session or temp directory unwritable**: Roundcube under cPanel uses `/usr/local/cpanel/base/3rdparty/roundcube/temp/`. Confirm it exists and is writable by the cPanel user context, and that `/tmp` is not mounted `noexec` with an old `sessions` setting. Check `df -h /tmp`.

- **Clock skew between the browser and server**: session cookies expire immediately if the server clock is hours out. `chronyc tracking`.

- **Proxy or Cloudflare stripping cookies**: if webmail is behind a proxy that rewrites the `Set-Cookie` header or the hostname differs between the form post and the redirect (mixed `webmail.example.com` and `hostname:2096`), the session cookie is never presented. Test directly against `https://hostname:2096` to rule the proxy in or out.

- **Dovecot 2.4 auth changes**: a login that works in a mail client but loops in Roundcube after an update is sometimes a stale IMAP host setting in the Roundcube config; `update-roundcube --force` rewrites it.

The Roundcube error log is the quickest confirmation:

```
tail -50 /usr/local/cpanel/base/3rdparty/roundcube/logs/errors.log
tail -50 /usr/local/cpanel/logs/error_log | grep -i roundcube
```

## A common pitfall: switching back ends

Changing the Tweak Setting from SQLite to MySQL (or the reverse) triggers a conversion that walks every mail account. On a server with tens of thousands of mailboxes it takes a long time, and if it is interrupted, half the accounts are on each back end and one half gets the database error. Run the conversion out of hours, watch `/usr/local/cpanel/logs/roundcube_convert_log` (the name varies slightly by build; check the changelog), and if it was interrupted, run `/usr/local/cpanel/bin/convert_roundcube_mysql2sqlite` or its counterpart to finish it.

## Verify

Log in to webmail as the affected account through **cPanel » Email Accounts » Check Email**, open Contacts and Settings, and change and save a preference. That exercises reads and writes on every table that matters. Then confirm the log has stayed quiet:

```
tail -5 /usr/local/cpanel/base/3rdparty/roundcube/logs/errors.log
```

For the MySQL back end, add the `roundcube` database to whatever backup and `mysqlcheck` schedule you already run; the [MySQL health snapshot script](/scripts/mysql-health-snapshot/) reports crashed tables before users hit them.

## Roundcube database error at a glance

**Official documentation:** [cPanel & WHM documentation](https://docs.cpanel.net/), [RFC 5321 (SMTP)](https://www.rfc-editor.org/rfc/rfc5321), [Linux man pages](https://man7.org/linux/man-pages/).

**Related guides:** [Email forwarders with MailBaby: SRS, strict forwarding errors and backoffs](https://srvscripts.com/guides/mailbaby-srs-strict-forwarding-errors/) · [Find the source of outgoing spam on a cPanel server](https://srvscripts.com/guides/find-source-of-outgoing-spam-cpanel/) · [Choosing a VPS for a cPanel or DirectAdmin server in 2026](https://srvscripts.com/guides/best-vps-for-cpanel-directadmin-server/).

## Frequently asked questions

### Does the Roundcube database error mean email has been lost?

No. Roundcube’s database only stores contacts, identities, preferences and sessions. Mail itself lives in Dovecot’s maildirs, so even recreating the Roundcube database from scratch leaves every message in place.

### Is it safe to run update-roundcube –force on a live cPanel server?

Yes. The script is idempotent: it recreates only what is missing, applies pending schema migrations and rewrites the config with working credentials. Users may see a brief interruption to webmail while it runs, but nothing is deleted.

### Why does Roundcube work on port 2096 but loop behind Cloudflare or a proxy?

The session cookie is being dropped or rewritten. A proxy that alters the `Set-Cookie` header, or a hostname mismatch between the login post and the redirect, means the browser never presents the session, so Roundcube shows the form again. Fix the proxy rule or use a consistent webmail hostname.
