config to use redis unix socket ignored; connection still tries host+port and fails

Created on 4 February 2023, almost 2 years ago
Updated 17 April 2024, 7 months ago

I've installed Drupal 10 & Drush 11

	vendor/bin/drush status | egrep "Drupal version|Drush version"
		Drupal version   : 10.0.3
		Drush version    : 11.4.0

and

	composer -V
		Composer version 2.5.1 2022-12-22 15:33:54

	php -v
		PHP 8.2.2 (cli) (built: Jan 31 2023 13:31:55) (NTS gcc x86_64)

	redis-server -v
		Redis server v=7.0.8 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=85aed731497b4b06

	rpm -qa | grep php.*redis
		php-pecl-redis5-5.3.7-2.fc37.remi.8.2.x86_64

	composer show | grep redis
		drupal/redis    1.6.0    Integration of Drupal with the Redis key-value store.

My Drupal site's up & running.

I'm trying to add Redis caching.

redis-server runs

	ps ax | grep redis
	  858 ?        Ssl    4:26 /usr/bin/redis-server unixsocket:/run/redis/redis.sock

	ls -al /run/redis/redis.sock
		srwxrwx--- 1 redis www 0 Feb  4 07:39 /run/redis/redis.sock=

and is accessible over socket,

	redis-cli -s /run/redis/redis.sock -a 'myRedisPass' INFO keyspace

		# Keyspace
		db0:keys=68,expires=2,avg_ttl=464283493

I installed & enabled the redis module

	composer require 'drupal/redis:^1.6'
	vendor/bin/drush -y pm:enable redis

When I add to Drupal settings.php

	$settings['redis.connection']['interface'] = 'PhpRedis';
	$settings['cache']['default'] = 'cache.backend.redis';
	$conf['redis_cache_socket'] = '/run/redis/redis.sock';
	$settings['redis.connection']['base'] = 0;
	$settings['redis.connection']['password'] = 'myRedisPassXXXXXXXXXXXXXXXXXXXXXX';
	$settings['container_yamls'][] = 'modules/contrib/redis/example.services.yml';
	$settings['queue_default'] = 'queue.redis_reliable';
	$settings['redis.connection']['persistent'] = TRUE;

and access the site, I get

	The website encountered an unexpected error. Please try again later.

In logs, I see it's trying to connect to host+port, not the unix socket.

	==> /var/log/nginx/php-fpm.log <==
	[04-Feb-2023 07:50:50 America/New_York] RedisException: Connection refused in /home/www/drupal/web/modules/contrib/redis/src/Client/PhpRedis.php on line 29 #0 /home/www/drupal/web/modules/contrib/redis/src/Client/PhpRedis.php(29): Redis->pconnect('127.0.0.1', 6379)
	#1 /home/www/drupal/web/modules/contrib/redis/src/ClientFactory.php(173): Drupal\redis\Client\PhpRedis->getClient('127.0.0.1', 6379, 0, 'myRedisPassXXXXX...', Array, true)
	#2 /home/www/drupal/web/modules/contrib/redis/src/Cache/RedisCacheTagsChecksum.php(49): Drupal\redis\ClientFactory::getClient()
	#3 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(259): Drupal\redis\Cache\RedisCacheTagsChecksum->__construct(Object(Drupal\redis\ClientFactory))
	#4 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService(Array, 'cache_tags.inva...')
	#5 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(434): Drupal\Component\DependencyInjection\Container->get('cache_tags.inva...', 1)
	#6 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(237): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
	#7 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService(Array, 'cache.backend.r...')
	#8 /home/www/drupal/web/core/lib/Drupal/Core/Cache/CacheFactory.php(83): Drupal\Component\DependencyInjection\Container->get('cache.backend.r...')
	#9 [internal function]: Drupal\Core\Cache\CacheFactory->get('page')
	#10 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(255): call_user_func_array(Array, Array)
	#11 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService(Array, 'cache.page')
	#12 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(434): Drupal\Component\DependencyInjection\Container->get('cache.page', 1)
	#13 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(237): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
	#14 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService(Array, 'http_middleware...')
	#15 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(434): Drupal\Component\DependencyInjection\Container->get('http_middleware...', 1)
	#16 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(237): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
	#17 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService(Array, 'http_middleware...')
	#18 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(434): Drupal\Component\DependencyInjection\Container->get('http_middleware...', 1)
	#19 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(237): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
	#20 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService(Array, 'http_middleware...')
	#21 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(434): Drupal\Component\DependencyInjection\Container->get('http_middleware...', 1)
	#22 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(237): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
	#23 /home/www/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService(Array, 'http_kernel')
	#24 /home/www/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(1373): Drupal\Component\DependencyInjection\Container->get('http_kernel')
	#25 /home/www/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(681): Drupal\Core\DrupalKernel->getHttpKernel()
	#26 /home/www/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
	#27 {main}

Connections to the same redis server via socket from other php frameworks (Wordpress & Grav) have no connection problems.

<!--break-->
🐛 Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024