Nextcloud Preview Generation Fails — Complete Guide
In this tutorial, you'll learn about Nextcloud Preview Generation Fails. We cover key concepts, practical examples, and best practices.
Hook
You browse your Nextcloud Photos folder — every image shows a grey placeholder instead of a thumbnail. Opening an image loads it fine, but the preview grid is entirely blank. Preview generation is stuck or disabled.
The Wrong Way
Disabling preview generation entirely to fix the broken thumbnails means you lose the visual grid in Files and Photos — a poor trade-off.
# BAD: Disabling previews
sudo -u www-data php occ config:app:set files enable_previews --value="no"
Previews disabled — all images show as generic file icons
You replaced broken previews with no previews.
The Right Way
Identify why the preview generator is failing — usually it is a missing PHP extension or out-of-memory error.
# 1. Check the Nextcloud log for preview errors
tail -100 /var/www/nextcloud/data/nextcloud.log | grep -i "preview\|imagick\|thumbnail"
{"message":"Preview generation failed for file 1234: Class 'Imagick' not found"}
The Imagick PHP extension is missing. Install it:
# 2. Install the Imagick PHP extension
sudo apt install php8.3-imagick
sudo systemctl restart php8.3-fpm
# 3. Verify Imagick is available
php -m | grep imagick
imagick
# 4. Regenerate previews for existing files
sudo -u www-data php occ preview:generate-all -vvv
Generating previews for 1250 files
Progress: 100%
If Imagick is installed but previews still fail, increase the preview memory limit:
# Increase preview memory in config.php
sudo -u www-data php occ config:system:set preview_max_memory --value="512"
Prevention
- Install
php-imagickduring initial Nextcloud setup. - Set
preview_max_memoryto at least256(MB) in config.php. - Enable the
Preview Generatorapp from the Nextcloud App Store for background generation. - Run
occ preview:generate-allafter bulk photo imports. - Keep ImageMagick system packages updated (ghostscript, libmagickwand).
Advanced Troubleshooting
Check the Logs
Most TOOL errors are logged to stdout or a dedicated log file. Check your logs first:
# Check system logs
journalctl -u tool --since "1 hour ago"
# Or check the application log
tail -50 ~/.tool/logs/error.log
Test with a Minimal Example
Create the simplest possible tool configuration to verify the base setup works:
tool --version
tool --help
If the minimal test passes, add configuration options one at a time until you find the breaking change.
Common Configuration Mistakes
- Using the wrong file path or URL in configuration
- Forgetting to restart TOOL after changing config files
- Mixing tabs and spaces in YAML configuration files
- Setting incorrect permissions on configuration directories
When to Reinstall
If none of the above resolves the issue, consider a clean reinstall:
# Backup your configuration
cp -r ~/.tool ~/.tool.bak
# Remove and reinstall
# Follow the official TOOL installation guide
This ensures you start from a known good state and can isolate the issue.
Common Mistakes with preview gen
- Using
foldlinstead offoldl'causing stack overflow on large lists - Forgetting
deriving (Show, Eq)on custom data types needed for debugging - Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
These mistakes appear frequently in real-world NEXTCLOUD code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
DodaTech — previews that show your content, not placeholders.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro