NC - Internal Server Error

Nextcloud version (eg, 12.0.2): 14 (something, I can’t confirm it)
Operating system and version (eg, Ubuntu 17.04): Raspbian 9.11
Apache or nginx version (eg, Apache 2.4.25): 2.4.25
PHP version (eg, 7.1): 7.0.33

The issue you are facing:

Is this the first time you’ve seen this error? (Y/N): Yes

Steps to replicate it:

When I try to access to my Nextcloud I got this error message:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

I already check the folder permissions on root nextcloud folder and also the data folder:

Root nextcloud folder:

drwxr-xr-x 14 www-data www-data  4096 Feb 22 16:41 .
drwxr-xr-x  3 www-data www-data  4096 Jul  8  2019 ..
drwxr-xr-x 32 www-data www-data  4096 Oct  1 10:00 3rdparty
drwxr-xr-x 42 www-data www-data  4096 Oct  1 23:34 apps
-rw-r--r--  1 www-data www-data 12063 Oct  1 10:00 AUTHORS
drwxr-xr-x  2 www-data www-data  4096 Feb 27 22:38 config
-rw-r--r--  1 www-data www-data  3650 Oct  1 10:00 console.php
-rw-r--r--  1 www-data www-data 34520 Oct  1 10:00 COPYING
drwxr-xr-x 19 www-data www-data  4096 Oct  1 10:00 core
-rw-r--r--  1 www-data www-data  4979 Oct  1 10:00 cron.php
-rw-r--r--  1 www-data www-data  2928 Oct  1 15:35 .htaccess
-rw-r--r--  1 www-data www-data   156 Oct  1 10:01 index.html
-rw-r--r--  1 www-data www-data  3172 Oct  1 10:01 index.php
drwxr-xr-x  6 www-data www-data  4096 Oct  1 10:00 lib
-rw-r--r--  1 www-data www-data   283 Oct  1 10:01 occ
drwxr-xr-x  2 www-data www-data  4096 Oct  1 10:00 ocm-provider
drwxr-xr-x  2 www-data www-data  4096 Oct  1 10:00 ocs
drwxr-xr-x  2 www-data www-data  4096 Oct  1 10:00 ocs-provider
-rw-r--r--  1 www-data www-data  2951 Oct  1 10:01 public.php
-rw-r--r--  1 www-data www-data  5139 Oct  1 10:01 remote.php
drwxr-xr-x  4 www-data www-data  4096 Oct  1 10:00 resources
-rw-r--r--  1 www-data www-data    26 Oct  1 10:01 robots.txt
drwxr-xr-x 12 www-data www-data  4096 Oct  1 10:00 settings
-rw-r--r--  1 www-data www-data  2232 Oct  1 10:01 status.php
drwxr-xr-x  3 www-data www-data  4096 Oct  1 10:01 themes
drwxr-xr-x  2 www-data www-data  4096 Jul  9  2019 updater
-rw-r--r--  1 www-data www-data   163 Oct  1 10:00 .user.ini
-rw-r--r--  1 www-data www-data   364 Oct  1 10:00 version.php

Data folder:

drwxr-x--- 7 www-data www-data 4096 Feb 22 16:20 data

Right now I don’t know where I can troubleshoot this issue and solve it. So I need help to make some troubleshoot and got a solution for this.

The output of your Nextcloud log in Admin > Logging:

I can't access to Nextcloud to retrieve the logs.

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

<?php
$CONFIG = array (
  'instanceid' => 'xxxxxxx',
  'passwordsalt' => 'xxxxxxxxxxx',
  'secret' => 'xxxxxxxxx',
  'trusted_domains' => 
  array (
    0 => 'my.domain.org',
  ),
  'datadirectory' => '/media/pi/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '15.0.12.1',
  'overwrite.cli.url' => 'http://my.domain.org',
  'dbname' => 'nextcloud_db',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'xxxxx',
  'dbpassword' => 'xxxxxxx',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'localhost',
    'port' => 6379,
  ),
  'twofactor_enforced' => 'false',
  'twofactor_enforced_groups' => 
  array (
  ),
  'twofactor_enforced_excluded_groups' => 
  array (
  ),
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'meysql.utf8mb4' => true,
  'mysql.utf8mb4' => true,
  'updater.secret' => 'xxxxxxxxx',
);

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

stat: cannot stat '/media/pi/nextcloud/data/appdata_ocxjgpim1lbv/js/core/merged-template-prepend.js.deps': Permission denied
[Thu Feb 27 22:38:36.251113 2020] [:error] [pid 18613] [client xxx.xxx.xxx.xxx:50445] PHP Warning:  fileperms(): stat failed for /media/pi/nextcloud/data/nextcloud.log in /var/www/html/my.domain.org/$
[Thu Feb 27 22:38:36.251216 2020] [:error] [pid 18613] [client xxx.xxx.xxx.xxx:50445] {"reqId":"XoVbxZJ5TvU9B8Ulqifc","level":3,"time":"2020-02-27T22:38:36+00:00","remoteAddr":"93.108.50.238","user":"--","$
[Thu Feb 27 22:38:36.261008 2020] [:error] [pid 18613] [client xxx.xxx.xxx.xxx:50445] PHP Warning:  fileperms(): stat failed for /media/pi/nextcloud/data/nextcloud.log in /var/www/html/my.domain.org/$
[Thu Feb 27 22:38:36.261129 2020] [:error] [pid 18613] [client xxx.xxx.xxx.xxx:50445] {"reqId":"XoVbxZJ5TvU9B8Ulqifc","level":3,"time":"2020-02-27T22:38:36+00:00","remoteAddr":"93.108.50.238","user":"--","$
[Thu Feb 27 22:38:36.266125 2020] [:error] [pid 18613] [client xxx.xxx.xxx.xxx:50445] PHP Warning:  fileperms(): stat failed for /media/pi/nextcloud/data/nextcloud.log in /var/www/html/my.domain.org/$
[Thu Feb 27 22:38:36.266245 2020] [:error] [pid 18613] [client xxx.xxx.xxx.xxx:50445] {"reqId":"XoVbxZJ5TvU9B8Ulqifc","level":3,"time":"2020-02-27T22:38:36+00:00","remoteAddr":"93.108.50.238","user":"--","$
[Thu Feb 27 22:38:36.266319 2020] [:error] [pid 18613] [client xxx.xxx.xxx.xxx:50445] {"reqId":"XoVbxZJ5TvU9B8Ulqifc","level":4,"time":"2020-02-27T22:38:36+00:00","remoteAddr":"93.108.50.238","user":"--","$
[Thu Feb 27 22:38:36.268245 2020] [:error] [pid 18613] [client xxx.xxx.xxx.xxx:50445] PHP Warning:  fileperms(): stat failed for /media/pi/nextcloud/data/nextcloud.log in /var/www/html/my.domain.org/$
[Thu Feb 27 22:38:36.268344 2020] [:error] [pid 18613] [client xxx.xxx.xxx.xxx:50445] {"reqId":"XoVbxZJ5TvU9B8Ulqifc","level":3,"time":"2020-02-27T22:38:36+00:00","remoteAddr":"93.108.50.238","user":"--","$
[Thu Feb 27 22:38:36.268417 2020] [:error] [pid 18613] [client xxx.xxx.xxx.xxx:50445] {"reqId":"XoVbxZJ5TvU9B8Ulqifc","level":3,"time":"2020-02-27T22:38:36+00:00","remoteAddr":"93.108.50.238","user":"--","$

Well, there seems something to be wrong with your drive. Is it an external drive an still mounted, is it too full (check with df -h, there should be an extra line for mounted external drives, anything that is 100% full can cause a problem)

Can you check the permissions? sudo -u www-data ls -lisa /media/pi/nextcloud/data/
Even if the permissions for the data folder are ok, www-data must be able to get to the data folder, so you must be able to go through the parent folders as well.

It went out of support, you should consider upgrading to NC 16 (requires php > 7.0).

Hi,
Yes, this is a external drive and isn’t full, here’s the output of df -h:

/dev/sda1 1.8T 586G 1.2T 34% /media/pi/nextcloud

Also run the other command sudo -u www-data ls -lisa /media/pi/nextcloud/data/, output:
ls: cannot access '/media/pi/nextcloud/data/': Permission denied

Then I re-run the command sudo chown -R www-data:www-data /media/pi/nextcloud/ and then sudo chmod 750 /media/pi/nextcloud/data/, restarted apache server sudo service apache2 restart and still not access to.

Please check permissions of parent folders (media and pi), too.
If www-data cannot access these, the webserver user won’t be able to access the child folders.

You could additionally check if your drive is mounted read only for some reason
sudo mount will give you an overview (‘rw’ or ‘ro’)

Hi,
Now the problem is solve. I performed these commands to solve the issue:
sudo chown -R www-data:www-data /media/pi/
sudo chmod 750 /media/pi/
sudo service apache2 restart

Thank you all for the help to solve this issue.

1 Like