[SOLVED] Can't make redis work without socket? (no error log)

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • Nextcloud Hub 10 (31.0.0)
  • Operating system and version (e.g., Ubuntu 24.04):
    • Debian 12
  • Web server and version :
    • nginx 1.22.1
  • Reverse proxy and version
    • none
  • PHP version (e.g, 8.3):
    • 8.3
  • Is this the first time you’ve seen this error? (Yes / No):
    • I never tried configuring a memcache on nextcloud before
  • When did this problem seem to first start?
    • When I use redis for memcache
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Bare metal, following nextcloud tutorial if I recall corectly
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • Yes, Cloudflare, but here we're in localhost so...

Summary of the issue you are facing:

I already use redis for some other apps on my server, so:

  1. I know it works
  2. I don’t really want to edit the config of all my apps to use the socket Here is the redis part of my config:
  'redis' => [
     'host' => 'localhost',
     'port' => 6379,
],
//'memcache.local' => '\\OC\\Memcache\\APCu',
//'memcache.distributed' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => 'true',
'memcache.locking' => '\\OC\\Memcache\\Redis',

As soon as I uncoment one of the two commented lines, nextcloud crashes without any log I tried and successed accessing redis throug redis-cli. Any idea?

Steps to replicate it (hint: details matter!):

  1. Use my config, wich is also on nexcloud documentation
  2. Install redis
  3. Cry

Log entries

Nextcloud

None, despite getting this message on the page:

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.

Web Browser

some 500 errors (one for the page, one for the favicon^^)

Web server / Reverse Proxy

No error log but 500 errors in access.log of course

172.71.123.186 - - [15/Apr/2025:13:18:47 +0200] "GET /settings/admin/overview HTTP/2.0" 500 289 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36"
172.71.127.60 - - [15/Apr/2025:13:18:48 +0200] "GET /favicon.ico HTTP/2.0" 500 289 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36"
172.71.232.34 - - [15/Apr/2025:13:18:50 +0200] "GET /index.php/apps/files/preview-service-worker.js HTTP/2.0" 500 289 "https://nextcloud.mydomain.uk/index.php/apps/files/preview-service-worker.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36"
172.71.123.186 - - [15/Apr/2025:13:19:20 +0200] "PUT /ocs/v2.php/apps/user_status/api/v1/heartbeat?format=json HTTP/2.0" 500 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36"
172.71.123.186 - - [15/Apr/2025:13:19:20 +0200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/2.0" 500 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36"

Configuration

Useless for this case but will still give it

# Version 2024-07-17

upstream php-handler {
    #server 127.0.0.1:9000;
    server unix:/run/php/php8.3-fpm.sock;
}

# Set the `immutable` cache control options only for assets with a cache busting `v` argument
map $arg_v $asset_immutable {
    "" "";
    default ", immutable";
}

server {
    listen 80;
    server_name nextcloud.mydomain.uk;

    # Prevent nginx HTTP Server Detection
    server_tokens off;

    # Enforce HTTPS

        return 301 https://$server_name$request_uri;


}

server {
    listen 443 ssl http2;
    # With NGinx >= 1.25.1 you should use this instead:
    # listen 443      ssl;
    # listen [::]:443 ssl;
    # http2 on;

    # Path to the root of your installation
    root /var/www/html/nextcloud;
types {
    text/javascript mjs;
}
  # enables SSLv3/TLSv1, but not SSLv2 which is weak and should no longer be used.
  ssl_protocols SSLv3 TLSv1.3;

  # disables all weak ciphers
  ssl_ciphers ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM;

  server_name nextcloud.mydomain.uk;

  ## Keep alive timeout set to a greater value for SSL/TLS.
  keepalive_timeout 7500 7500;

  ## See the keepalive_timeout directive in nginx.conf.
  ## Server certificate and key.
  ssl on;
  ssl_certificate /etc/letsencrypt/live/mydomain.uk/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/mydomain.uk/privkey.pem;
  ssl_session_timeout  120m;

    # Prevent nginx HTTP Server Detection
    server_tokens off;

    # HSTS settings
    # WARNING: Only add the preload option once you read about
    # the consequences in https://hstspreload.org/. This option
    # will add the domain to a hardcoded list that is shipped
    # in all major browsers and getting removed from this list
    # could take several months.
    #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload" always;

    # set max upload size and increase upload timeout:
    client_max_body_size 200G;
    client_body_timeout 5000s;

    fastcgi_buffers 64 4K;

    # Enable gzip but do not remove ETag headers
    gzip on;
    gzip_vary on;
    gzip_comp_level 4;
    gzip_min_length 256;
    gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
    gzip_types application/atom+xml text/javascript application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

    # Pagespeed is not supported by Nextcloud, so if your server is built
    # with the `ngx_pagespeed` module, uncomment this line to disable it.
    #pagespeed off;

    # The settings allows you to optimize the HTTP2 bandwidth.
    # See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/
    # for tuning hints
    client_body_buffer_size 512k;

    # HTTP response headers borrowed from Nextcloud `.htaccess`
    add_header Referrer-Policy                   "no-referrer"       always;
    add_header X-Content-Type-Options            "nosniff"           always;
    add_header X-Frame-Options                   "SAMEORIGIN"        always;
    add_header X-Permitted-Cross-Domain-Policies "none"              always;
    add_header X-Robots-Tag                      "noindex, nofollow" always;
    add_header X-XSS-Protection                  "1; mode=block"     always;
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload" always;



    # Remove X-Powered-By, which is an information leak
    fastcgi_hide_header X-Powered-By;

    # Set .mjs and .wasm MIME types
    # Either include it in the default mime.types list
    # and include that list explicitly or add the file extension
    # only for Nextcloud like below:
    include mime.types;
    types {
        text/javascript mjs;
        application/wasm wasm;
    }

    # Specify how to handle directories -- specifying `/index.php$request_uri`
    # here as the fallback means that Nginx always exhibits the desired behaviour
    # when a client requests a path that corresponds to a directory that exists
    # on the server. In particular, if that directory contains an index.php file,
    # that file is correctly served; if it doesn't, then the request is passed to
    # the front-end controller. This consistent behaviour means that we don't need
    # to specify custom rules for certain paths (e.g. images and other assets,
    # `/updater`, `/ocs-provider`), and thus
    # `try_files $uri $uri/ /index.php$request_uri`
    # always provides the desired behaviour.
    index index.php index.html /index.php$request_uri;

    # Rule borrowed from `.htaccess` to handle Microsoft DAV clients
    location = / {
        if ( $http_user_agent ~ ^DavClnt ) {
            return 302 /remote.php/webdav/$is_args$args;
        }
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # Make a regex exception for `/.well-known` so that clients can still
    # access it despite the existence of the regex rule
    # `location ~ /(\.|autotest|...)` which would otherwise handle requests
    # for `/.well-known`.
    location ^~ /.well-known {
        # The rules in this block are an adaptation of the rules
        # in `.htaccess` that concern `/.well-known`.

        location = /.well-known/carddav { return 301 /remote.php/dav/; }
        location = /.well-known/caldav  { return 301 /remote.php/dav/; }

        location /.well-known/acme-challenge    { try_files $uri $uri/ =404; }
        location /.well-known/pki-validation    { try_files $uri $uri/ =404; }

        # Let Nextcloud's API for `/.well-known` URIs handle all other
        # requests by passing them to the front-end controller.
        return 301 /index.php$request_uri;
    }

    # Rules borrowed from `.htaccess` to hide certain paths from clients
    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/)  { return 404; }
    location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console)                { return 404; }

    # Ensure this block, which passes PHP files to the PHP process, is above the blocks
    # which handle static assets (as seen below). If this block is not declared first,
    # then Nginx will encounter an infinite rewriting loop when it prepends `/index.php`
    # to the URI, resulting in a HTTP 500 error response.
    location ~ \.php(?:$|/) {
        # Required for legacy support
        rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /index.php$request_uri;

        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        set $path_info $fastcgi_path_info;

        try_files $fastcgi_script_name =404;

        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param HTTPS on;

        fastcgi_param modHeadersAvailable true;         # Avoid sending the security headers twice
        fastcgi_param front_controller_active true;     # Enable pretty urls
        fastcgi_pass php-handler;

        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;

        fastcgi_max_temp_file_size 0;
    }

    # Serve static files
    location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac|mjs)$ {
        try_files $uri /index.php$request_uri;
        # HTTP response headers borrowed from Nextcloud `.htaccess`
        add_header Cache-Control                     "public, max-age=15778463$asset_immutable";
        add_header Referrer-Policy                   "no-referrer"       always;
        add_header X-Content-Type-Options            "nosniff"           always;
        add_header X-Frame-Options                   "SAMEORIGIN"        always;
        add_header X-Permitted-Cross-Domain-Policies "none"              always;
        add_header X-Robots-Tag                      "noindex, nofollow" always;
        add_header X-XSS-Protection                  "1; mode=block"     always;
        access_log off;     # Optional: Don't log access to assets
    }

    location ~ \.(otf|woff2?)$ {
        try_files $uri /index.php$request_uri;
        expires 7d;         # Cache-Control policy borrowed from `.htaccess`
        access_log off;     # Optional: Don't log access to assets
    }

    # Rule borrowed from `.htaccess`
    location /remote {
        return 301 /remote.php$request_uri;
    }

    location / {
        try_files $uri $uri/ /index.php$request_uri;
    }
}

Nextcloud

<?php
$CONFIG = array (
  'instanceid' => 'thisissecret',
  'passwordsalt' => 'E/thisissecret',
  'secret' => 'thisissecret',
  'trusted_domains' =>
  array (
    0 => 'nextcloud.mydomain.uk',
  ),
  'datadirectory' => '/var/www/html/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '31.0.0.18',
  'overwrite.cli.url' => 'https://nextcloud.mydomain.uk',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '3306',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'thisissecret',
  'installed' => true,
  'app_install_overwrite' =>
  array (
    1 => 'integration_pexip',
    2 => 'snappymail',
  ),
  'mail_from_address' => 'no-reply@mydomain.uk',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'mydomain.uk',
  'mail_smtphost' => 'mail.mydomain.uk',
  'mail_smtpport' => '587',
  'mail_smtpauth' => true,
  'mail_smtptimeout' => 30,
  'mail_smtpname' => 'no-reply@mydomain.uk',
  'mail_smtppassword' => '7Cfd2b995c8!',
  'maintenance_window_start' => 1,
  'maintenance' => false,
  'mail_smtpsecure' => 'ssl',
  'default_phone_region' => 'FR',
  'redis' => [
     'host' => 'localhost',
     'port' => 6379,
],
  'log_rotate_size' => 5242880,
'memcache.local' => '\\OC\\Memcache\\APCu',
//'memcache.distributed' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => 'true',
'memcache.locking' => '\\OC\\Memcache\\Redis',
);

Apps

The output of occ app:list (if possible).

Enabled:
  - activity: 4.0.0
  - app_api: 5.0.2
  - bruteforcesettings: 4.0.0
  - circles: 31.0.0-dev.0
  - cloud_federation_api: 1.14.0
  - comments: 1.21.0
  - contactsinteraction: 1.12.0
  - dashboard: 7.11.0
  - dav: 1.33.0
  - federatedfilesharing: 1.21.0
  - federation: 1.21.0
  - files: 2.3.1
  - files_downloadlimit: 4.0.0
  - files_pdfviewer: 4.0.0
  - files_reminders: 1.4.0
  - files_sharing: 1.23.1
  - files_trashbin: 1.21.0
  - files_versions: 1.24.0
  - firstrunwizard: 4.0.0
  - integration_pexip: 1.0.4
  - logreader: 4.0.0
  - lookup_server_connector: 1.19.0
  - nextcloud_announcements: 3.0.0
  - notifications: 4.0.0
  - oauth2: 1.19.1
  - password_policy: 3.0.0
  - photos: 4.0.0-dev.1
  - privacy: 3.0.0
  - profile: 1.0.0
  - provisioning_api: 1.21.0
  - recommendations: 4.0.0
  - related_resources: 2.0.0
  - serverinfo: 3.0.0
  - settings: 1.14.0
  - sharebymail: 1.21.0
  - snappymail: 2.38.2
  - support: 3.0.0
  - survey_client: 3.0.0
  - systemtags: 1.21.1
  - text: 5.0.0
  - theming: 2.6.1
  - twofactor_backupcodes: 1.20.0
  - updatenotification: 1.21.0
  - user_status: 1.11.0
  - viewer: 4.0.0
  - weather_status: 1.11.0
  - webhook_listeners: 1.2.0
  - workflowengine: 2.13.0
Disabled:
  - admin_audit: 1.21.0
  - encryption: 2.19.0
  - files_external: 1.23.0
  - suspicious_login: 9.0.1
  - twofactor_nextcloud_notification: 5.0.0
  - twofactor_totp: 13.0.0-dev.0
  - user_ldap: 1.22.0

An internal server error / 500 will be either logged by Nextcloud (if it gets that far) or by your web server error log. Please check the latter for additional hints about what is going on.

Also, please post the actual output of occ config:list system as suggested in the support template. This will show the actual parsed/merged configuration.

hi
Here is how I proceed to configure Redis on Nextcloud:

Adding the user www-data to the redis group:
sudo usermod -a -G redis www-data

redis.conf file configuration:

sudo sed -i -e "s/^#* *port +*6379$/port 0/g" /etc/redis/redis.conf
sudo sed -i -e "s/^#* *unixsocket +*.*$/unixsocket \/var\/run\/redis\/redis-server.sock/g" /etc/redis/redis.conf
sudo sed -i -e "s/^#* *unixsocketperm+*.*$/unixsocketperm 770/g" /etc/redis/redis.conf

Verification :
sudo cat /etc/redis/redis.conf | egrep "^#* *port +|^#* *unixsocket +|^#* *unixsocketperm +"
Nextcloud-redis-conf
Restarting Redis:
sudo systemctl restart redis-server.service

File Locking and Memory Cache:
Enabling filelocking:
sudo -u www-data php /var/www/nextcloud/occ config:system:set filelocking.enabled --value="true"

Redis Configuration:

sudo -u www-data php /var/www/nextcloud/occ config:system:set redis host --value="/var/run/redis/redis-server.sock"
sudo -u www-data php /var/www/nextcloud/occ config:system:set redis port --value="0"
sudo -u www-data php /var/www/nextcloud/occ config:system:set redis timeout --value="0.0"

Configuring memcache.distributed (to be done after configuring Redis):
sudo -u www-data php /var/www/nextcloud/occ config:system:set memcache.distributed --value="\OC\Memcache\Redis"

Configuring memcache.local and memcache.locking:

sudo -u www-data php /var/www/nextcloud/occ config:system:set memcache.local --value="\OC\Memcache\Redis"
sudo -u www-data php /var/www/nextcloud/occ config:system:set memcache.locking --value="\OC\Memcache\Redis"

Verification :

sudo cat /var/www/nextcloud/config/config.php | \
	egrep "'filelocking\.enabled|'memcache\.local\
	|'memcache\.locking|'host|'port|'timeout|'memcache\.distributed"

Restart Apache:
sudo systemctl restart apache2.service

Config.php:

  'redis' => 
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => '0',
    'timeout' => '0.0',
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',

As I said, the nextcloud log file is completely empty, and the nginx error file doesn’t show anything related to my problem (showing errors several hours before my problem, because I had done something wrong)

Here is the config with the command, in the meantime I put everything in APCu to fix the problem temporary

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "nextcloud.monptitserveur.uk"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "31.0.0.18",
        "overwrite.cli.url": "https:\/\/nextcloud.monptitserveur.uk",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "3306",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "app_install_overwrite": {
            "1": "integration_pexip",
            "2": "snappymail"
        },
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpauth": true,
        "mail_smtptimeout": 30,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "maintenance_window_start": 1,
        "maintenance": false,
        "mail_smtpsecure": "ssl",
        "default_phone_region": "FR",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "log_rotate_size": 5242880,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.locking": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\APCu"
    }
}

As I said in my post, I don’t really want to switch to the socket because I would have to reconfigure my other apps using Redis.
The localhost is a suported way to do this and this thread could be useful to other users that wants to do it like that

What happens if you run something like occ status after setting up Redis?

1 Like
OCP\HintException: [0]: Memcache OC\Memcache\Redis not available for distributed cache (Is the matching PHP module installed and enabled?)

I needed php-redis package!
sudo apt install php8.3-redis

I also had to put back my config as before: someone suggested me to put “redis” as host to solve the problem, but it didn’t work because I didn’t register it in the hosts file.
Putting it back to localhost made it work.

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.