How to Connect Redis via Socket in Shopware 6
When using Redis as a caching layer in Shopware 6, the standard method involves connecting via a hostname and port specified in the .env or .env.local files.
However, if Redis is running as a Unix socket service, the connection setup needs a different approach. This article explains how to resolve connection issues when Redis is configured via socket in a Shopware 6 environment.
Problem OverviewConnect Redis via Socket in Shopware 6
In many production or containerized environments, Redis runs as a service and can be accessed through a hostname (like 127.0.0.1) and port (e.g., 6379).
Shopware 6 allows this configuration through environment variables like:
1 | REDIS_URL=redis://localhost:6379 |
But if Redis is running via a Unix socket (e.g., /run/redis/redis.sock), attempting to configure the socket path directly through the .env file does not work as expected.
This leads to failure in establishing a Redis connection for caching.
Solution to connect Redis via socket in Shopware
To connect Redis through a socket in Shopware 6, you need to define the connection explicitly in the config/packages/cache.yaml file instead of relying solely on environment variables.
Update config/packages/cache.yaml
Modify the file with the following configuration:
framework:
1 2 3 4 5 6 7 | cache: app: cache.adapter.redis_tag_aware system: cache.adapter.redis_tag_aware default_redis_provider: redis:///run/redis_restsq/redis.sock |
Replace /run/redis_restsq/redis.sock with the actual path to your Redis socket if it differs.
This configuration ensures that Shopware’s caching system can successfully communicate with Redis over a Unix socket.
Why This Works
Shopware’s environment variable parsing does not currently support Redis socket paths out-of-the-box via .env files. However, directly setting the default_redis_provider inside the Symfony configuration allows Shopware to recognize and use the socket-based Redis connection properly.
Conclusion
Connecting to Redis via a socket in Shopware 6 requires manual configuration within the Symfony cache settings. By updating the cache.yaml file, you ensure stable Redis communication even when using a Unix socket setup.
Need help setting up Redis or optimizing your Shopware store? Our team offers expert Shopware services tailored to your business and goals.
Recent help desk articles

Greetings! I'm Aneesh Sreedharan, CEO of 2Hats Logic Solutions. At 2Hats Logic Solutions, we are dedicated to providing technical expertise and resolving your concerns in the world of technology. Our blog page serves as a resource where we share insights and experiences, offering valuable perspectives on your queries.
