After migrating the shop to a new server, product images were not displaying – grey placeholders instead. The database had file paths, but the files did not exist on disk. Fix time: 5 hours.
Symptoms
- Grey placeholders instead of product images
- Image URLs return 404
- Database has correct paths in
catalog_product_entity_media_gallery - Directory
pub/media/catalog/productis empty or incomplete
Cause
Server migration skipped the pub/media directory or rsync failed halfway through the transfer.
Solution
# Compare file counts between servers find pub/media/catalog/product -name "*.jpg" -o -name "*.png" | wc -l ssh old-server "find /var/www/html/pub/media/catalog/product -type f | wc -l" # Sync media from old server rsync -avz --progress old-server:/var/www/html/pub/media/ /var/www/html/pub/media/ --exclude="cache/" rm -rf pub/media/catalog/product/cache/ bin/magento catalog:images:resize chown -R www-data:www-data pub/media/
Takeaways
The pub/media directory can contain gigabytes of data. Always verify file counts after migration by comparing find ... | wc -l on both servers. Store media on separate storage (S3, NFS) – server migration then does not touch the files.
