No image preview for users

For some reason users dont a preview for images on my neither of my 2 nextcloud instances. When logged in as admin it works but whenever I try to do that as a user I just get the vague error:
“Couldnt generate preview for this file.”

Couldnt find anything realted in the log. Any ideas?

Sorry to hear you’re facing problems :slight_frown:

If you’re urgently looking for support to keep your business running, consider checking out our paid support options.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the following as you can (you can cut and paste this into your topic):


Nextcloud version (eg, 10.0.2):
Operating system and version (eg, Ubuntu 16.04):
Apache or nginx version (eg, Apache 2.4.25):
PHP version (eg, 5.6):
Is this the first time you’ve seen this error?:

Can you reliably replicate it? (If so, please outline steps):

The issue you are facing:

The output of your Nextcloud log in Admin > Logging:

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

The output of your Apache/nginx/system log in /var/log/____:


Remember, this information may be requested if it isn’t supplied; for fastest response please provide as much as you can :heart: Feel free to use a pastebin service, otherwise log files can be indented with 4 spaces on each line to present them in a friendlier way on the forum.

Sorry for missing those things.
Nextcloud version: 11.0.3
operating system: RHEL Server 7.3
apache version: 2.4.6
PHP version: 7.0.19

Image Previews (jpg, png) files cant be preview/viewed from users. When logged in as admin the preview works.
Error: Couldnt generate preview for this file. I have 2 nextcloud instances that are connected to the same user directory (with nfs) and database (mariadb - galera cluster)

Nextcloud Log

Warning core Trusted domain error. “134.30.95.50” tried to access using “134.30.95.50” as host. 2017-06-26T07:43:52+0200
Warning core Trusted domain error. “134.30.95.50” tried to access using “134.30.95.50” as host. 2017-06-25T20:44:12+0200
Warning core Trusted domain error. “134.30.95.50” tried to access using “134.30.95.50” as host. 2017-06-25T12:06:21+0200
Warning core Trusted domain error. “134.30.95.50” tried to access using “134.30.95.50” as host. 2017-06-24T16:23:55+0200
Warning core Trusted domain error. “134.30.95.50” tried to access using “134.30.95.50” as host. 2017-06-24T15:50:34+0200
Warning core Trusted domain error. “134.30.95.50” tried to access using “134.30.95.50” as host. 2017-06-24T11:11:38+0200
Warning core Trusted domain error. “134.30.95.50” tried to access using “134.30.95.50” as host. 2017-06-23T23:57:45+0200
Warning core Trusted domain error. “134.30.95.50” tried to access using “134.30.95.50” as host. 2017-06-23T17:44:39+0200
Error files Sabre\HTTP\ClientException: Failed connect to oc.basisit.de:443; Connection refused 2017-06-23T12:32:32+0200
Error index Doctrine\DBAL\Exception\DriverException: An exception occurred while executing ‘SELECT id FROM nc_jobs WHERE (class = ?) AND (argument = ?) LIMIT 1’ with params [“OC\Log\Rotate”, “"\/var\/www\/nextcloud\/data\/nextcloud.log"”]: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away 2017-06-23T12:32:17+0200
Error PHP PDOStatement::execute(): Error reading result set’s header at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php#91 2017-06-23T12:32:17+0200
Error core Doctrine\DBAL\Exception\DriverException: An exception occurred while executing ‘SELECT uid, displayname FROM nc_users WHERE LOWER(uid) = LOWER(?)’ with params [“admin”]: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away 2017-06-23T12:32:17+0200
Error PHP PDOStatement::execute(): MySQL server has gone away at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php#91 2017-06-23T12:32:17+0200
Error core Doctrine\DBAL\Exception\DriverException: An exception occurred while executing ‘SELECT uid, displayname FROM nc_users WHERE LOWER(uid) = LOWER(?)’ with params [“admin”]: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away 2017-06-23T12:32:17+0200
Error index Doctrine\DBAL\Exception\DriverException: An exception occurred while executing ‘SELECT uid, displayname FROM nc_users WHERE LOWER(uid) = LOWER(?)’ with params [“admin”]: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away 2017-06-23T12:32:17+0200
Error PHP PDOStatement::execute(): Error reading result set’s header at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php#91 2017-06-23T12:32:17+0200
Error PHP PDOStatement::execute(): MySQL server has gone away at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php#91 2017-06-23T12:32:17+0200
Warning core Trusted domain error. “134.30.95.50” tried to access using “134.30.95.50” as host.

config.php:

Nothing related in apache/system log.

That could do it.

In your conf you’ve listed the DB server via hostname, can you switch that to IP and give it another go please?
Failing that, we’ll need to see MySQL logs too.

Other things:

  • overwrite.cli.url shouldn’t be localhost. You’re asking the server to overwrite http://cloud.mydomain.com with http://localhost which can lead to errors loading images, resources, and more.
  • redis might serve you better if you opt for socket rather than IP on the same server. See here

Changed it to IP but that didnt change anything for that part.
Also removed the overwrite.cli.url. (Never added that on purpose. One instance hda it on localhost, the other on nc (lb address.)

For MySQL logs I am a bid confused. (Not to used to mysql/mariadb.) There is no dedicated log (mysql/mysql.log or mysql.log) under /var/log. Global Variable error_log is empty. A few related things are in /var/log/messages.

But I just got a few additions in the nextcloud log of my second instance. Not sure if they are related. Last time I got a similiar Error the nfs mount for userdata was not mounted. This time it is.

Error PHP fclose() expects parameter 1 to be resource, boolean given at /var/www/nextcloud/lib/private/Files/Storage/Local.php#218 2017-06-26T10:53:20+0200
Error PHP fread() expects parameter 1 to be resource, boolean given at /var/www/nextcloud/lib/private/Files/Storage/Local.php#217 2017-06-26T10:53:20+0200
Error PHP fopen(/nc-data/appdata_ocukryt2ztzg/preview/17757/32-32-crop.png): failed to open stream: No such file or directory at /var/www/nextcloud/lib/private/Files/Storage/Local.php#216 2017-06-26T10:53:20+0200
Error PHP filesize(): stat failed for /nc-data/appdata_ocukryt2ztzg/preview/17757/32-32-crop.png at /var/www/nextcloud/lib/private/Files/Storage/Local.php#211 2017-06-26T10:53:20+0200
Error PHP fclose() expects parameter 1 to be resource, boolean given at /var/www/nextcloud/lib/private/Files/Storage/Local.php#218 2017-06-26T10:53:20+0200
Error PHP fread() expects parameter 1 to be resource, boolean given at /var/www/nextcloud/lib/private/Files/Storage/Local.php#217 2017-06-26T10:53:20+0200
Error PHP fopen(/nc-data/appdata_ocukryt2ztzg/preview/18983/32-32-crop.png): failed to open stream: No such file or directory at /var/www/nextcloud/lib/private/Files/Storage/Local.php#216 2017-06-26T10:53:20+0200
Error PHP filesize(): stat failed for /nc-data/appdata_ocukryt2ztzg/preview/18983/32-32-crop.png at /var/www/nextcloud/lib/private/Files/Storage/Local.php#211 2017-06-26T10:53:20+0200