[SOLVED] Internal Server Error, unable to access Nextcloud

First of all, thanks for yout help in advance.

Background:
My Proxmox Virtual Environment had a sudden shutdown due to system overload (I believe) and my containers were all okay except for the one with Turnkey Linux (Debian 10 but they set up stuff like Nextcloud for you). I get the error above when I try to access the web interface. My desktop app on Linux shows a simliar error. I thought that I could fix the problem by upgrading my Nextcloud instance up a version since the one I was using was out of date anyways. I successfully did this, but the issue still persisted.

In nextcloud.log, I have a whole bunch of errors because I have a few devices that keep trying to connect to it when I activate apache2, here is one example line from my phone trying to connect to it:

{"reqId":"2JFRLHdDjHzs6jqxOYKA","level":3,"time":"2021-06-22T14:29:49+00:00","remoteAddr":"192.168.86.250","user":"--","app":"core","method":"GET","url":"/index.php/204","message":{"Exception":"OC\\HintException","Message":"Memcache \\OC\\Memcache\\Redis not available for local cache","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/Server.php","line":682,"function":"__construct","class":"OC\\Memcache\\Factory","type":"->","args":["5a2af02718608b5816c7a24bd0e1d0f0",{"__class__":"OC\\Log"},"\\OC\\Memcache\\Redis","\\OC\\Memcache\\Redis","\\OC\\Memcache\\Redis"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":155,"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":118,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":122,"function":"offsetGet","class":"Pimple\\Container","type":"->","args":["OC\\Memcache\\Factory"]},{"file":"/var/www/nextcloud/lib/private/ServerContainer.php","line":156,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OC\\Memcache\\Factory",true]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":56,"function":"query","class":"OC\\ServerContainer","type":"->","args":["OC\\Memcache\\Factory"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":177,"function":"get","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OC\\Memcache\\Factory"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":155,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":114,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":122,"function":"offsetGet","class":"Pimple\\Container","type":"->","args":["OCP\\ICacheFactory"]},{"file":"/var/www/nextcloud/lib/private/ServerContainer.php","line":156,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OCP\\ICacheFactory",true]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":87,"function":"query","class":"OC\\ServerContainer","type":"->","args":["OCP\\ICacheFactory",true]},{"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":101,"function":"array_map","args":[{"__class__":"Closure"},[{"name":"config","__class__":"ReflectionParameter"},"*** sensitive parameter replaced ***",{"name":"request","__class__":"ReflectionParameter"},{"name":"router","__class__":"ReflectionParameter"}]]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":109,"function":"buildClass","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":[{"name":"OC\\URLGenerator","__class__":"ReflectionClass"}]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":126,"function":"resolve","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OC\\URLGenerator"]},{"file":"/var/www/nextcloud/lib/private/ServerContainer.php","line":156,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OC\\URLGenerator",true]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":56,"function":"query","class":"OC\\ServerContainer","type":"->","args":["OC\\URLGenerator"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":177,"function":"get","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OC\\URLGenerator"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":155,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":114,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":122,"function":"offsetGet","class":"Pimple\\Container","type":"->","args":["OCP\\IURLGenerator"]},{"file":"/var/www/nextcloud/lib/private/ServerContainer.php","line":156,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OCP\\IURLGenerator",true]},{"file":"/var/www/nextcloud/lib/private/Server.php","line":1653,"function":"query","class":"OC\\ServerContainer","type":"->","args":["OCP\\IURLGenerator"]},{"file":"/var/www/nextcloud/lib/private/Server.php","line":1134,"function":"getURLGenerator","class":"OC\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":155,"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":118,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":122,"function":"offsetGet","class":"Pimple\\Container","type":"->","args":["OC\\Template\\JSCombiner"]},{"file":"/var/www/nextcloud/lib/private/ServerContainer.php","line":156,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["OC\\Template\\JSCombiner",true]},{"file":"/var/www/nextcloud/lib/private/TemplateLayout.php","line":362,"function":"query","class":"OC\\ServerContainer","type":"->","args":["OC\\Template\\JSCombiner"]},{"file":"/var/www/nextcloud/lib/private/TemplateLayout.php","line":194,"function":"findJavascriptFiles","class":"OC\\TemplateLayout","type":"::","args":[["core/js/dist/main","js/dist/files_fileinfo","js/dist/files_client","js/merged-template-prepend","core/l10n/en"]]},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Template.php","line":183,"function":"__construct","class":"OC\\TemplateLayout","type":"->","args":["error",""]},{"file":"/var/www/nextcloud/lib/private/Template/Base.php","line":132,"function":"fetchPage","class":"OC_Template","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Template.php","line":332,"function":"printPage","class":"OC\\Template\\Base","type":"->","args":[]},{"file":"/var/www/nextcloud/index.php","line":55,"function":"printExceptionErrorPage","class":"OC_Template","type":"::","args":[{"__class__":"OC\\HintException"},500]}],"File":"/var/www/nextcloud/lib/private/Memcache/Factory.php","Line":98,"Hint":"Is the matching PHP module installed and enabled?","CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.15.1","version":"20.0.0.9"}

I noticed the hint “Is the matching PHP module installed and enabled” and I believe that might be part of the issue but I’m not sure what to get from it.

Nextcloud version (eg, 20.0.5): 20.0.0.9 was 19.*
Operating system and version (eg, Ubuntu 20.04): Debian 10/ Turnkey
Apache or nginx version (eg, Apache 2.4.25): 2.4.38-3
PHP version (eg, 7.4): 7.3

The issue you are facing:

I am unable to access the web interface or have applications (such as the Nextcloud desktop and mobile app) due to an Internal Server Error.

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

Steps to replicate it:

I’m not sure of the steps to replicate the problem, but I’m sure you could try sudden stopping of the operating system your Nextcloud instance is on.

The output of your Nextcloud log in Admin > Logging:

I can’t access it.

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

<?php
$CONFIG = array (
[REDACTED]
 'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'matthew-ct0.lan',
    2 => '192.168.86.*',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '20.0.0.9',
  'overwrite.cli.url' => 'http://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
[REDACTED]
 'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'instanceid' => '009b90ab566c2',
  'maintenance' => true,
  'loglevel' => 2,
  'encryption.legacy_format_support' => true,
  'encryption.key_storage_migrated' => false,
);

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

[Tue Jun 22 00:01:57.501210 2021] [ssl:warn] [pid 484] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 00:01:57.502034 2021] [ssl:warn] [pid 484] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 00:01:57.502332 2021] [mpm_prefork:notice] [pid 484] AH00163: Apache/2.4.38 (Debian) OpenSSL/1.1.1d configured -- resuming normal operations
[Tue Jun 22 00:01:57.502347 2021] [core:notice] [pid 484] AH00094: Command line: '/usr/sbin/apache2'
[Tue Jun 22 01:52:09.914873 2021] [ssl:warn] [pid 240] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 01:52:09.924164 2021] [ssl:warn] [pid 240] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 01:52:20.971553 2021] [ssl:warn] [pid 546] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 01:52:20.972392 2021] [ssl:warn] [pid 546] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 01:52:20.978696 2021] [mpm_prefork:notice] [pid 546] AH00163: Apache/2.4.38 (Debian) OpenSSL/1.1.1d configured -- resuming normal operations
[Tue Jun 22 01:52:20.978736 2021] [core:notice] [pid 546] AH00094: Command line: '/usr/sbin/apache2'
[Tue Jun 22 02:20:22.503694 2021] [mpm_prefork:notice] [pid 546] AH00169: caught SIGTERM, shutting down
[Tue Jun 22 02:20:43.052382 2021] [ssl:warn] [pid 245] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 02:20:43.053770 2021] [ssl:warn] [pid 245] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 02:20:55.332755 2021] [ssl:warn] [pid 457] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 02:20:55.333603 2021] [ssl:warn] [pid 457] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 02:20:55.339186 2021] [mpm_prefork:notice] [pid 457] AH00163: Apache/2.4.38 (Debian) OpenSSL/1.1.1d configured -- resuming normal operations
[Tue Jun 22 02:20:55.339220 2021] [core:notice] [pid 457] AH00094: Command line: '/usr/sbin/apache2'
[Tue Jun 22 02:27:10.639051 2021] [mpm_prefork:notice] [pid 457] AH00169: caught SIGTERM, shutting down
[Tue Jun 22 12:37:53.002133 2021] [ssl:warn] [pid 14613] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 12:37:53.034200 2021] [ssl:warn] [pid 14613] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 12:37:53.458828 2021] [ssl:warn] [pid 14614] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 12:37:53.459651 2021] [ssl:warn] [pid 14614] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 12:37:53.468392 2021] [mpm_prefork:notice] [pid 14614] AH00163: Apache/2.4.38 (Debian) OpenSSL/1.1.1d configured -- resuming normal operations
[Tue Jun 22 12:37:53.468429 2021] [core:notice] [pid 14614] AH00094: Command line: '/usr/sbin/apache2'
[Tue Jun 22 13:30:52.539757 2021] [php7:error] [pid 14619] [client 192.168.86.227:34874] script '/var/www/nextcloud/status.php' not found or unable to stat
[Tue Jun 22 13:31:54.529763 2021] [php7:error] [pid 14618] [client 192.168.86.227:34876] script '/var/www/nextcloud/status.php' not found or unable to stat
[Tue Jun 22 13:32:56.533193 2021] [php7:error] [pid 14617] [client 192.168.86.227:34878] script '/var/www/nextcloud/status.php' not found or unable to stat
[Tue Jun 22 13:41:12.544094 2021] [php7:error] [pid 14621] [client 192.168.86.227:34898] script '/var/www/nextcloud/status.php' not found or unable to stat
[Tue Jun 22 13:41:12.544284 2021] [autoindex:error] [pid 14621] [client 192.168.86.227:34898] AH01276: Cannot serve directory /var/www/nextcloud/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
[Tue Jun 22 13:41:12.547585 2021] [autoindex:error] [pid 14621] [client 192.168.86.227:34898] AH01276: Cannot serve directory /var/www/nextcloud/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
[Tue Jun 22 14:06:40.736244 2021] [mpm_prefork:notice] [pid 14614] AH00169: caught SIGTERM, shutting down
[Tue Jun 22 14:07:49.592291 2021] [ssl:warn] [pid 26302] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 14:07:49.593498 2021] [ssl:warn] [pid 26302] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 14:07:49.793600 2021] [ssl:warn] [pid 26303] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 14:07:49.794409 2021] [ssl:warn] [pid 26303] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 14:07:49.800300 2021] [mpm_prefork:notice] [pid 26303] AH00163: Apache/2.4.38 (Debian) OpenSSL/1.1.1d configured -- resuming normal operations
[Tue Jun 22 14:07:49.800342 2021] [core:notice] [pid 26303] AH00094: Command line: '/usr/sbin/apache2'
[Tue Jun 22 14:08:03.135542 2021] [mpm_prefork:notice] [pid 26303] AH00169: caught SIGTERM, shutting down
[Tue Jun 22 14:15:19.609462 2021] [ssl:warn] [pid 26441] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 14:15:19.610332 2021] [ssl:warn] [pid 26441] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 14:15:19.677826 2021] [ssl:warn] [pid 26442] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 14:15:19.678728 2021] [ssl:warn] [pid 26442] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Tue Jun 22 14:15:19.685162 2021] [mpm_prefork:notice] [pid 26442] AH00163: Apache/2.4.38 (Debian) OpenSSL/1.1.1d configured -- resuming normal operations
[Tue Jun 22 14:15:19.685200 2021] [core:notice] [pid 26442] AH00094: Command line: '/usr/sbin/apache2'

looks liek nextcloud lost connection to redis.

restart of all involved containers should solve the problem.

I rebooted the lxc container and it did not resolve the issue.

Alright, I figured out the solution.

First, ensure that redis-server is running and enabled.
Next, installphp-dev and make and run pecl install redis.
Then, add extension=redis.so to all php.ini files. Try this command: vim -p $(find /etc -iname php.ini) to make this process a little easier.
Lastly, restart your php fpm service, apache2, and redis-server.
And you are set.

Thanks, Reiner_Nippes, for pointing out the Redis connection error. I would have been lost.