# Failed to get Session with redis

**URL:** <https://forum.shopware.com/t/failed-to-get-session-with-redis/102573>\
**Category:** Shopware 5\
**Created:** [18. Januar 2024 um 17:16 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573 "2024-01-18T17:16:24Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![IT-ServiceLange](https://avatars.discourse-cdn.com/v4/letter/i/3ec8ea/32.png) [@IT-ServiceLange](https://forum.shopware.com/u/IT-ServiceLange)\
**Post date:** [18. Januar 2024 um 17:16 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573/1 "2024-01-18T17:16:24Z")

</div>

I getting the following error, when I try to use the redis cache:

```auto
[18-Jan-2024 18:10:10 Europe/Berlin] PHP Fatal error: Uncaught Zend_Session_Exception:
Zend_Session::start() - /home/fallguys/public_html/engine/Library/Zend/Session.php(Line:468): Error 
#2 session_start(): Failed to read session data: files (path: tcp://127.0.0.1:6379) in /home/fallguys
/public_html/engine/Library/Zend/Session.php:481

```

It is working in another shopware 5 instance, but on this here, it is not working, and I don’t know what I make wrong.

config.php

```auto
  'session' => array(
    'save_handler' => 'redis',
    'save_path' => "tcp://127.0.0.1:6379",
  ),

```

Ping the Cache

```auto
[fallguys@web01 public_html]$ redis-cli ping
PONG

```

Redis 6.2.7  
AlmaLinux/CloudLinux 8.9  
PHP 7.4.33  
Shopware 5.6.9

---

<div class="post-metadata">

**Author:** ![SCOOPEX](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/scoopex/32/18328_2.png) [@SCOOPEX](https://forum.shopware.com/u/SCOOPEX)\
**Post date:** [18. Januar 2024 um 18:08 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573/2 "2024-01-18T18:08:00Z")

</div>

Hi,

maybe your Redis Server is listening to the socket only (you can check in your /etc/redis/redis.conf file).

If so, try:

```auto
'session' => [
    'save_handler' => 'redis',
    'save_path' => "/var/run/redis/redis-server.sock",
  ],

```

PS. Socket connections are faster than a TCP connection.

Regards

---

<div class="post-metadata">

**Author:** ![IT-ServiceLange](https://avatars.discourse-cdn.com/v4/letter/i/3ec8ea/32.png) [@IT-ServiceLange](https://forum.shopware.com/u/IT-ServiceLange)\
**Post date:** [18. Januar 2024 um 18:10 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573/3 "2024-01-18T18:10:47Z")

</div>

Hi, no tcp is working fine. Teset it with netstat -lnp and with telnet 127.0.0.1 6379  
Cannot use sockets, because of a chroot/cagefs security environment on cPanel server.

---

<div class="post-metadata">

**Author:** ![SCOOPEX](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/scoopex/32/18328_2.png) [@SCOOPEX](https://forum.shopware.com/u/SCOOPEX)\
**Post date:** [18. Januar 2024 um 18:24 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573/4 "2024-01-18T18:24:03Z")

</div>

> [@IT-ServiceLange](#):
>
> `redis-cli ping`

Hm, maybe this helps in a cPanel / CageFS environment:

> **[Redis installation - 
		
		CloudLinux Community Forum](https://forum.cloudlinux.com/forum/cloudlinux-os-features/lve-limits-and-lve-manager/30927-)**
>
> I realize there are instructions here, to setup/integrate redis into a CloudLinux...

---

<div class="post-metadata">

**Author:** ![IT-ServiceLange](https://avatars.discourse-cdn.com/v4/letter/i/3ec8ea/32.png) [@IT-ServiceLange](https://forum.shopware.com/u/IT-ServiceLange)\
**Post date:** [18. Januar 2024 um 18:28 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573/5 "2024-01-18T18:28:14Z")

</div>

Is there any known bug with PHP 7.4.33 and PECL Redis Module?  
the log says `Failed to read session data: files` why „files“ ?? it should be redis. Because of this, it seems to be files are used, it cannot read from filesystem path tcp://…, would be logical.  
It should switch to redis.

---

<div class="post-metadata">

**Author:** ![SCOOPEX](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/scoopex/32/18328_2.png) [@SCOOPEX](https://forum.shopware.com/u/SCOOPEX)\
**Post date:** [18. Januar 2024 um 18:37 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573/6 "2024-01-18T18:37:34Z")

</div>

The message is correct - your PHP session files will be stored in Memory (Redis) instead of the file-system.

Using `redis-cli monitor` you can check the activity, here´s some sample output of a Shopware 5 Shop (running Almalinux 8, Cloudlinux, CageFS with Plesk):

1705602752.644828 [0 127.0.0.1:52020] „SETEX“ „PHPREDIS\_SESSION:nqp7elvu4lfe0kuutf1lu1nor6“ „7200“ „ShopwareBackend|a:2:{s:12:"X-CSRF-Token";s:30:"MIkyl0R5siTmUxRp6jgbJJLbxtXCkk";s:4:"Auth";O:8:"stdClass":18:{s:2:"id";s:2:"50";s:6:"roleID";s:1:"1";s:8:"username";s:9:"xxxxxx";s:8:"password";s:60:"xxxxxxxxxxxxxxxxx";s:7:"encoder";s:6:"bcrypt";s:6:"apiKey";s:40:"udmRMPaN4uBzStL9zz3gEdig9zDHOUvMggqTwom4";s:8:"localeID";s:1:"1";s:9:"sessionID";s:26:"5tvh9m97insa3bgb7one269ado";s:9:"lastlogin";s:19:"2024-01-18 14:45:26";s:4:"name";s:13:"Administrator";s:5:"email";s:30:"xxxxxxxxxxxxxxxxx";s:6:"active";s:1:"1";s:12:"failedlogins";s:1:"0";s:11:"lockeduntil";s:19:"2020-06-07 20:13:42";s:15:"extended\_editor";s:1:"1";s:14:"disabled\_cache";s:1:"0";s:4:"role";O:25:"Shopware\Models\User\Role":11:{s:29:"\x00Shopware\Models\User\Role\x00id";i:1;s:35:"\x00Shopware\Models\User\Role\x00parentId";N;s:31:"\x00Shopware\Models\User\Role\x00name";s:12:"local\_admins";s:38:"\x00Shopware\Models\User\Role\x00description";s:53:"Default group that gains access to all shop functions";s:33:"\x00Shopware\Models\User\Role\x00source";s:8:"build-in";s:34:"\x00Shopware\Models\User\Role\x00enabled";i:1;s:32:"\x00Shopware\Models\User\Role\x00admin";i:1;s:32:"\x00Shopware\Models\User\Role\x00users";O:33:"Doctrine\ORM\PersistentCollection":2:{s:13:"\x00\*\x00collection";O:43:"Doctrine\Common\Collections\ArrayCollection":1:{s:53:"\x00Doctrine\Common\Collections\ArrayCollection\x00elements";a:0:{}}s:14:"\x00\*\x00initialized";b:0;}s:32:"\x00Shopware\Models\User\Role\x00rules";O:33:"Doctrine\ORM\PersistentCollection":2:{s:13:"\x00\*\x00collection";O:43:"Doctrine\Common\Collections\ArrayCollection":1:{s:53:"\x00Doctrine\Common\Collections\ArrayCollection\x00elements";a:0:{}}s:14:"\x00\*\x00initialized";b:0;}s:35:"\x00Shopware\Models\User\Role\x00children";O:33:"Doctrine\ORM\PersistentCollection":2:{s:13:"\x00\*\x00collection";O:43:"Doctrine\Common\Collections\ArrayCollection":1:{s:53:"\x00Doctrine\Common\Collections\ArrayCollection\x00elements";a:0:{}}s:14:"\x00\*\x00initialized";b:0;}s:33:"\x00Shopware\Models\User\Role\x00parent";N;}s:6:"locale";O:27:"Shopware\Models\Shop\Locale":4:{s:31:"\x00Shopware\Models\Shop\Locale\x00id";i:1;s:35:"\x00Shopware\Models\Shop\Locale\x00locale";s:5:"de\_DE";s:37:"\x00Shopware\Models\Shop\Locale\x00language";s:7:"Deutsch";s:38:"\x00Shopware\Models\Shop\Locale\x00territory";s:11:"Deutschland";}}}\_symfony\_flashes|a:0:{}\_sf2\_meta|a:3:{s:1:"u";i:1705602752;s:1:"c";i:1705602720;s:1:"l";i:0;}“

Maybe post your redis.conf here.

The Shop mentioned above is using PHP 7.4.33 with the following Redis Setup in config.php:

```auto
'session' => [
    'save_handler' => 'redis',
    'save_path' => "127.0.0.1:6379",
  ],

  'backendsession' => [
    'save_handler' => 'redis',
    'save_path' => "127.0.0.1:6379",
  ],

```

---

<div class="post-metadata">

**Author:** ![SCOOPEX](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/scoopex/32/18328_2.png) [@SCOOPEX](https://forum.shopware.com/u/SCOOPEX)\
**Post date:** [18. Januar 2024 um 18:46 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573/7 "2024-01-18T18:46:10Z")

</div>

> [@IT-ServiceLange](#):
>
> ```auto
> 'session' => array(
> 'save_handler' => 'redis',
> 'save_path' => "tcp://127.0.0.1:6379",
> ),
> 
> ```

Try to remove `tcp://` like shown in my example.

Here´s the Redis Version I am using:

```auto
[root@srv01 httpdocs]# redis-cli INFO server
# Server
redis_version:5.0.3
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:14b81d825631ff0c
redis_mode:standalone
os:Linux 4.18.0-513.9.1.lve.el8.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:8.4.1
process_id:1058
run_id:451d60649ab0a98afc0930dcd369a2cb5ce49e0d
tcp_port:6379
uptime_in_seconds:1801822
uptime_in_days:20
hz:10
configured_hz:10
lru_clock:11104639
executable:/usr/bin/redis-server
config_file:/etc/redis.conf
[root@srv01 httpdocs]#

```

---

<div class="post-metadata">

**Author:** ![SCOOPEX](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/scoopex/32/18328_2.png) [@SCOOPEX](https://forum.shopware.com/u/SCOOPEX)\
**Post date:** [18. Januar 2024 um 18:49 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573/8 "2024-01-18T18:49:50Z")

</div>

> [@IT-ServiceLange](#):
>
> Redis 6.2.7

PS. Your issue could be related to Redis 6.x where authentication has been introduced:

> **[Redis security](https://redis.io/docs/management/security/)**
>
> Security model and features in Redis

---

<div class="post-metadata">

**Author:** ![IT-ServiceLange](https://avatars.discourse-cdn.com/v4/letter/i/3ec8ea/32.png) [@IT-ServiceLange](https://forum.shopware.com/u/IT-ServiceLange)\
**Post date:** [18. Januar 2024 um 18:54 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573/9 "2024-01-18T18:54:33Z")

</div>

Well, that’s another great mistake. Somehow a PHP version has crept into the CageFS account that has no redis.so module loaded.

Now I have one Shopware account that works and another that doesn’t, on the same CloudLinux/cPanel server.

In both cases, however, „Redis“ is active as a module in the configuration.  
I’ll have to research this further and ask cPanel support if necessary.

By creating phpinfo() files I was able to track down the error.

Very strange!

---

<div class="post-metadata">

**Author:** ![SCOOPEX](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/scoopex/32/18328_2.png) [@SCOOPEX](https://forum.shopware.com/u/SCOOPEX)\
**Post date:** [18. Januar 2024 um 18:58 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573/10 "2024-01-18T18:58:49Z")

</div>

Try

```auto
/usr/sbin/cagefsctl --disable username
/usr/sbin/cagefsctl --force-update 
/usr/sbin/cagefsctl --enable username

```

---

<div class="post-metadata">

**Author:** ![IT-ServiceLange](https://avatars.discourse-cdn.com/v4/letter/i/3ec8ea/32.png) [@IT-ServiceLange](https://forum.shopware.com/u/IT-ServiceLange)\
**Post date:** [18. Januar 2024 um 19:04 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573/11 "2024-01-18T19:04:17Z")

</div>

Had no effect… redis is not shown in phpinfo

---

<div class="post-metadata">

**Author:** ![SCOOPEX](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/scoopex/32/18328_2.png) [@SCOOPEX](https://forum.shopware.com/u/SCOOPEX)\
**Post date:** [18. Januar 2024 um 19:08 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573/12 "2024-01-18T19:08:00Z")

</div>

Hm, the only other idea I had is that authentication may be enabled in your Redis 6 config and since you´re not providing a username/password in your config.php that this may cause the error (I am not sure if Shopware 5 even supports authentication).

But since you´re saying the other shop is working and the redis-php module missing in the CageFS setup of the other user it´s indeed pretty strange.

---

<div class="post-metadata">

**Author:** ![IT-ServiceLange](https://avatars.discourse-cdn.com/v4/letter/i/3ec8ea/32.png) [@IT-ServiceLange](https://forum.shopware.com/u/IT-ServiceLange)\
**Post date:** [18. Januar 2024 um 19:08 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573/13 "2024-01-18T19:08:39Z")

</div>

I have found a way!  
I have switched to ea-php74 in MultiPHP Manager, after that I switched back to alt-php74 with Cloud Linux PHP Selector. Now redis modul is active!

---

<div class="post-metadata">

**Author:** ![SCOOPEX](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/scoopex/32/18328_2.png) [@SCOOPEX](https://forum.shopware.com/u/SCOOPEX)\
**Post date:** [18. Januar 2024 um 19:09 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573/14 "2024-01-18T19:09:29Z")

</div>

… sounds like the configuration update fixed it in cPanel.

---

<div class="post-metadata">

**Author:** ![IT-ServiceLange](https://avatars.discourse-cdn.com/v4/letter/i/3ec8ea/32.png) [@IT-ServiceLange](https://forum.shopware.com/u/IT-ServiceLange)\
**Post date:** [18. Januar 2024 um 19:12 UTC](https://forum.shopware.com/t/failed-to-get-session-with-redis/102573/15 "2024-01-18T19:12:33Z")

</div>

Thank you for the very quick and competent help here in the forum!
