[PHP] Error: Redis::connect(): connect() failed: No such file or directory at /var/www/nextcloud/lib/private/RedisFactory.php#90

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version: 18.04.3 LTS
Operating system and version: Ubuntu 17.04:
Apache or nginx version: Apache2 (not sure exact Version)
PHP version (eg, 7.1):

The issue you are facing:

[PHP] Error: Redis::connect(): connect() failed: No such file or directory at /var/www/nextcloud/lib/private/RedisFactory.php#90

CONSTANTLY lol

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

Steps to replicate it:

  1. Start the server
  2. auto upload to external storage
  3. profit

The output of your Nextcloud log in Admin > Logging:

see image above... that is all I can get, downloading the log has a lot of personal info in it due to the nature of the upload ... not sure what #90 means

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

https://pastebin.com/dZ2dNggs

I hope that I answered the basics… but I just wanted to add a few things that may help those that are willing to help me with this.

First, I am very basic, when it comes to my Linux abilities in general. I work IT by trade, but we use nothing but windows and this is kinda of a home project.

I updated to 18.04 LTS from 16.04, and updated from Nextcloud 15 to 17. Resolved a few basic errors that seemed quite common, and then everything was running good.

Well a few days ago, my wife noted that her pictures were getting a server error when using the auto upload from her android phone… So I checked the server and notices that ALL of my external storages were no longer working… they had Red X’s or Yellow Exclamation points: :Modified screen shot below:

These were all working since I configured them a couple of years ago.

After googling the heck out of this issue, I notice that there were a couple of threads that seemed relevant, but I am not able to reproduce the steps (Some times because I just plain don’t know what I am dealing with lol) But here are a few and the notes I have after trying some of the fixes:

My /etc/group already has :www-data after redis


Talked about checking the server status… Here is mine:

root@FAMILY-CLOUD:/var/log/apache2# service redis-server status
● redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-11-30 21:06:05 PST; 41min ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
  Process: 1807 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)
 Main PID: 1904 (redis-server)
    Tasks: 4 (limit: 4915)
   CGroup: /system.slice/redis-server.service
           └─1904 /usr/bin/redis-server 127.0.0.1:6379

Nov 30 21:06:04 FAMILY-CLOUD systemd[1]: Starting Advanced key-value store...
Nov 30 21:06:05 FAMILY-CLOUD systemd[1]: Started Advanced key-value store.

I noted that I could not fine the ‘redis.sock’ file, it was not in /var/run/redis or /tmp

root@FAMILY-CLOUD:/var/log/apache2# redis-cli -s /var/run/redis/redis.sock ping
Could not connect to Redis at /var/run/redis/redis.sock: No such file or directory

I tried to research that… but many of the results I got, mainly seem to be talking about modifying configuration files (mine looked like thiers) but no one talked about how to create this redis.sock file. any my gut is telling me that this is the issue.

Also, just for the sake of having it, here is the output of my RedisFactory.php:

<?php
/**
 * @copyright Copyright (c) 2016, ownCloud, Inc.
 *
 * @author Jörn Friedrich Dreyer <jfd@butonic.de>
 * @author Robin Appelman <robin@icewind.nl>
 * @author Robin McCorkell <robin@mccorkell.me.uk>
 *
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */

namespace OC;

class RedisFactory {
        /** @var  \Redis */
        private $instance;

        /** @var  SystemConfig */
        private $config;

        /**
         * RedisFactory constructor.
         *
         * @param SystemConfig $config
         */
        public function __construct(SystemConfig $config) {
                $this->config = $config;
        }

        private function create() {
                if ($config = $this->config->getValue('redis.cluster', [])) {
                        if (!class_exists('RedisCluster')) {
                                throw new \Exception('Redis Cluster support is not available');
                        }
                        // cluster config
                        if (isset($config['timeout'])) {
                                $timeout = $config['timeout'];
                        } else {
                                $timeout = null;
                        }
                        if (isset($config['read_timeout'])) {
                                $readTimeout = $config['read_timeout'];
                        } else {
                                $readTimeout = null;
                        }
                        if (isset($config['password']) && $config['password'] !== '') {
                                $this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout, false, $config['password']);
                        } else {
                                $this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout);
                        }

                        if (isset($config['failover_mode'])) {
                                $this->instance->setOption(\RedisCluster::OPT_SLAVE_FAILOVER, $config['failover_mode']);
                        }
                } else {

                        $this->instance = new \Redis();
                        $config = $this->config->getValue('redis', []);
                        if (isset($config['host'])) {
                                $host = $config['host'];
                        } else {
                                $host = '127.0.0.1';
                        }
                        if (isset($config['port'])) {
                                $port = $config['port'];
                        } else if ($host[0] !== '/') {
                                $port = 6379;
                        } else {
                                $port = null;
                        }
                        if (isset($config['timeout'])) {
                                $timeout = $config['timeout'];
                        } else {
                                $timeout = 0.0; // unlimited
                        }

                        $this->instance->connect($host, $port, $timeout);
                        if (isset($config['password']) && $config['password'] !== '') {
                                $this->instance->auth($config['password']);
                        }

                        if (isset($config['dbindex'])) {
                                $this->instance->select($config['dbindex']);
                        }
                }
        }

        public function getInstance() {
                if (!$this->isAvailable()) {
                        throw new \Exception('Redis support is not available');
                }
                if (!$this->instance instanceof \Redis) {
                        $this->create();
                }

                return $this->instance;
        }

        public function isAvailable() {
                return extension_loaded('redis')
                && version_compare(phpversion('redis'), '2.2.5', '>=');
        }
}

#82 is already set to :null:
and #90 is about passwords

Any help is appreciated … I am sorry if I provided too much or not the right please let me know what you need I will gladly get it

Thanks for the time to ready this book :smile:

I would recommend to start with the basics and check the Redis socket configuration. What is the output of the following command:

grep "^unix"  /etc/redis/redis.conf

Additionally it might help to monitor what is written to the Nextcloud log file. Based on your config.php file, it should have been created in the /var/www/nextcloud/data directory. Please make also sure that you set 'loglevel' => 0, in your Nextcloud onfiguration file.

1 Like

first and foremost… thank you for reading my post and for your suggestion.

I think you may have lead me down the right path, I first started by attempting to run your command and, then decided to see if that file was anywhere on the system at all, i ran the locate command for it:

root@FAMILY-CLOUD:/# grep "^unix"  /etc/redis/redis.conf
root@FAMILY-CLOUD:/# updatedb
root@FAMILY-CLOUD:/# locate redis.conf
/etc/redis/redis.conf
/etc/redis/redis.conf.dpkg-old
/var/lib/dpkg/info/php-redis.conffiles
root@FAMILY-CLOUD:/# grep "^unix"  /etc/redis/redis.conf.dpkg-old
unixsocket /var/run/redis/redis.sock
unixsocketperm 770

I bet that is the correct information in that old, file, and I could not help but notice that the location is not where the other forums were pointing

Should I restore the backup?

Based on the Redis system start command, which you’ve posted previously, the used configuration file is /etc/redis/redis.conf. The executed grep command showed that the relevant configuration entriesfor the socket seem to be missing from the file. Execute the following two commands and restart your Redis server afterwards:

echo "unixsocket /var/run/redis/redis.sock" >> /etc/redis/redis.conf
echo "unixsocketperm 770" >> /etc/redis/redis.conf
1 Like

Okay, ran the commands that you posted:

root@FAMILY-CLOUD:/# echo "unixsocket /var/run/redis/redis.sock" >> /etc/redis/redis.conf
root@FAMILY-CLOUD:/# echo "unixsocketperm 770" >> /etc/redis/redis.conf
root@FAMILY-CLOUD:/# systemctl restart redis
root@FAMILY-CLOUD:/# systemctl restart redis-server
root@FAMILY-CLOUD:/# service redis-server status
● redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2019-12-01 08:13:43 PST; 15s ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
  Process: 15677 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
  Process: 15680 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)
 Main PID: 15704 (redis-server)
    Tasks: 4 (limit: 4915)
   CGroup: /system.slice/redis-server.service
           └─15704 /usr/bin/redis-server 127.0.0.1:6379

Dec 01 08:13:43 FAMILY-CLOUD systemd[1]: Starting Advanced key-value store...
Dec 01 08:13:43 FAMILY-CLOUD systemd[1]: redis-server.service: Can't open PID file /var/run/redis/redis-server.pid (yet?) after start: No such file or directory
Dec 01 08:13:43 FAMILY-CLOUD systemd[1]: Started Advanced key-value store.

And I set the logging to ‘0’
The constant rolling error messages stopped (GREAT!!!) but the external storage are still showing down.

My log file is over 227MB, so I am waiting for notepad to finish showing it to me, most of it is seams to be

{"reqId":"RPWY2vyTjzd2h7AscBAD","level":0,"time":"2019-12-01T16:22:07+00:00","remoteAddr":"<myPublicIP>","user":"<myusername>","app":"core","method":"PROPFIND","url":"/ourcloud/remote.php/webdav/Music/","message":"could not get login credentials because the token is invalid","userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.9.0","version":"17.0.1.1","id":"5de3e8afd6423"}

strange considering no passwords have been changed, and even stranger considering that I am logged in with my Cloud Admin account right now for the page. I went ahead and disabled the music app since it is not official anyways

So the /var/run/redis/redis.sock file does now exist and you’re able to login to Nextcloud using the web gui?

image

that’s new…

This morning at 0730 Hours PST my main user account on the domain got locked out… and I think it is because Nextcloud is using some cached credentials and constantly loggin in with it, because the error log in the DC shows that the failed logins came ‘from’ the DC, so that indicates to me that it is from LDAP connect rather than logging into the serve, and to be honest this has been going on for months. I have yet to be able to narrow down the issue, or where the account is coming from. I just know it is my account.

So, with that being said, I wonder if that is the issue with the failed token is related… (I mean obviously it is /related/) but it should be noted that this issue has been going on since the middle of the week last week. So maybe a different unrelated problem all together?

But I am able to get onto next cloud using my admin account (and others) and running a quick locate command confirms that the file is present, though I could not search for it:

root@FAMILY-CLOUD:/# updatedb
root@FAMILY-CLOUD:/# locate redis.sock
root@FAMILY-CLOUD:/# cd /var/run/redis/
root@FAMILY-CLOUD:/var/run/redis# ls
redis-server.pid  redis.sock
root@FAMILY-CLOUD:/var/run/redis#

used a different browser and was able to log in… weird

also, my external storage are still not connecting …

spoke too soon… they are working now

So I got done checking everything out, and it all appears to be working, So I marked your echo commands as the solution, because that is what fixed it.

And for that I am very grateful!

But, due to my curious nature, I cant help but wonder what was caused this to happen. Was it a result of the upgrade from 16.04 to 18.04 or something else?

Thanks again @j-ed You are the best!

Thanks :slight_smile:

I assume that you’ve updated several packages on your server, including the Redis one. By default the socket interface hasn’t been configured in the new configuration file. You only found matches in an older configuration file ( /etc/redis/redis.conf.dpkg-old).
The echo commands added the required settings so that a restart reactivated the required socket interface.