Clear Nextcloud’s Missing Database Indexes Warning

Clear the Nextcloud “Database missing some indexes” warning by running occ db:add-missing-indices as the web server user from the correct Nextcloud installation. The command adds indexes defined by Nextcloud or installed apps but missing from the database; on current Nextcloud 35 documentation, --dry-run previews the SQL before it runs.

Nextcloud-style Administration Overview with an amber warning that the database is missing some indexes
The warning appears in Administration Overview when Nextcloud detects indexes missing from its database schema.

What the warning means

A database index is a lookup structure that helps the database find rows without scanning an entire table. Nextcloud and its apps sometimes add indexes to improve queries. An upgrade may leave that work for an administrator because creating an index on a large table can take time and affect performance while it runs. The missing-index warning is usually a maintenance prompt, not proof that files or database records are damaged.

Nextcloud’s current database command reference describes db:add-missing-indices as adding indexes that are in the expected schema but absent from the current installation. The current manual also documents --dry-run for previewing SQL statements. The exact indexes depend on your Nextcloud version and installed apps.

Prepare the server

  • Confirm which Nextcloud instance shows the warning, especially if you manage staging and production or more than one container.
  • Make sure a recent database backup exists and that you know how to restore it. This command changes database structure. Do not edit or drop indexes manually as a substitute.
  • Plan to run the command when database load is reasonable. The server can stay online for this operation according to Nextcloud’s upgrade guidance, but indexing a large table can take time and temporarily affect response speed.
  • Find the Nextcloud installation directory, the PHP CLI version used by the web server, and the web server’s operating-system account. The account is often www-data on Debian or Ubuntu, apache on Fedora or CentOS, and http on Arch Linux.

Nextcloud’s OCC guide explains that occ is the server’s command-line interface and must run as the HTTP user so file ownership and permissions remain consistent. Do not use www-data blindly if your installation uses a different account.

Preview and add the missing indexes

For a standard archive installation on Debian or Ubuntu, open a shell on the Nextcloud server and change to the directory containing the occ file. This example uses /var/www/nextcloud; your path may differ.

cd /var/www/nextcloud
sudo -E -u www-data php occ db:add-missing-indices --dry-run

The dry run prints the SQL it would execute without changing the database. Read the output and confirm that it is the expected maintenance operation. The --dry-run option is documented in the current Nextcloud 35 manual; if an older release rejects it, check that release’s command help rather than removing options at random.

A Linux terminal showing the Nextcloud OCC missing-index command with the dry-run option
Use the documented dry-run option to inspect the SQL before making a database change.

When you are ready to apply the change, run the command without --dry-run:

sudo -E -u www-data php occ db:add-missing-indices

Nextcloud checks the relevant tables and reports progress. Let it finish; do not interrupt the process just because a large table takes longer than expected. The upgrade manual lists this command among the longer schema tasks that can run while the instance stays online, so you normally do not need to enable maintenance mode for this repair. Avoid concurrent database maintenance while it is running.

A Linux terminal showing the missing-index command checking the filecache table and finishing with Done
The command checks database tables and returns to the shell when it finishes.

If Nextcloud runs in Docker

Run occ in the Nextcloud application container, not in the separate database container. For a container named nextcloud with the usual www-data account, the command is commonly:

docker exec --user www-data -it nextcloud php occ db:add-missing-indices

Replace nextcloud with your application container’s actual name. If your image or deployment uses a different container user, PHP binary, or command wrapper, follow that image’s documentation and keep the command running as the HTTP user.

Verify the warning is gone

After the command completes, refresh Administration settings > Overview. The missing-index message should disappear once Nextcloud’s check recognizes the indexes. You can also rerun the command; it should finish without needing to add the same missing indexes again. This confirms the schema check has caught up, though it does not measure overall database performance.

Nextcloud-style Administration Overview with the missing-index warning no longer displayed
Refresh the Administration Overview after the command finishes and check whether the database warning has cleared.

If the warning remains

  1. Confirm you ran the command against the same Nextcloud installation and database that produced the warning. A common mistake is executing it in a maintenance container, staging instance, or database container.
  2. Check that the command ran as the correct web server user and used the same PHP version as the web server. Nextcloud notes that a different CLI PHP configuration can cause occ errors.
  3. On Nextcloud 35 and later, run sudo -E -u www-data php occ db:schema:check to inspect schema differences. The current reference identifies this check as added in version 35. On earlier releases, use the diagnostics documented for that release.
  4. If the missing index belongs to a third-party app or the command reports an error, update the app if an update is available, review the Nextcloud log and command output, and ask the app maintainer or Nextcloud support with the exact index and table names. Do not run hand-written CREATE INDEX statements unless the app or database maintainer provides them for your exact schema.

For a production server, keep the database backup until the warning is cleared and the application is operating normally. Nextcloud’s upgrade guidance covers the online maintenance task and the optional dry run.

Leave a Comment

Clear Nextcloud’s Missing Database Indexes Warning

Clear Nextcloud’s Missing Database Indexes Warning

Run Nextcloud’s OCC repair safely, preview the database changes, and check why the warning might remain.

Raise Nextcloud’s Web Upload Limit Past 2 GB

Raise Nextcloud’s Web Upload Limit Past 2 GB

Allow larger Nextcloud browser uploads by aligning PHP, Nginx or Apache, temporary storage, and timeout settings—and verify which limit is blocking the file.

Clear Nextcloud’s PHP Memory Warning at the Web Server

Set the PHP memory limit Nextcloud actually uses, restart the right service, and confirm the 512 MB setting in Admin Overview.

Connect an S3-Compatible Bucket to Nextcloud External Storage

Mount a compatible object-storage bucket in Nextcloud using its S3 backend, with the right endpoint, credentials, access scope, and verification steps.

Move Nextcloud Data to an External Drive Without Breaking Storage

Move Nextcloud Data to an External Drive Without Breaking Storage

Safely move a Linux Nextcloud data directory to an external drive using a persistent UUID mount, maintenance mode, a verified copy, and the original-path symlink.

Nextcloud Database Error After an Update: What to Check First

Restore Nextcloud access after an update by diagnosing SQL errors, checking database connectivity, and safely completing interrupted migrations.

Reset a Lost Nextcloud Admin Password with OCC

Use Nextcloud’s OCC command to reset an administrator password from the server shell, with guidance for usernames, permissions, and external login providers.

Add the HSTS Header at the HTTPS Endpoint Serving Nextcloud

Clear Nextcloud’s HSTS warning by setting the header at Apache, NGINX, or your TLS proxy, then verify the public HTTPS response safely.

Troubleshoot Nextcloud App Installs That Report No Internet

Troubleshoot Nextcloud App Installs That Report No Internet

Trace App Store installation failures to DNS, HTTPS, proxy, TLS, or configuration issues from the Nextcloud server itself.

Tame Nextcloud Preview CPU Spikes with a Scheduled Queue

Move thumbnail work to a controlled background schedule, trim unused preview sizes, and verify the queue without overwhelming your Nextcloud server.