5👍
✅
The host name is what you call the container that runs Redis. For example, if your docker-compose contains something like this:
cache:
image: redis:3.2.6
then, you need to set the configuration to connect to cache:6379
0👍
Just adding to the below answer, the probable issue while using docker compose is referring to localhost directly. We must use the service name instead.
So if you are using in docker compose, redis like this:
cache:
image: redis:7-alpine
Then in settings.py, refer to the service like this:
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://cache:6379/1", # Note the cache
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
},
}
}
- [Django]-Django: Safely validating untrusted HTML input
- [Django]-How to return most popular items in a table, but where each item is unique?
- [Django]-How to expose Django/Python application to the web?
- [Django]-Is it ok to use Django Template Tag inside JS script
Source:stackexchange.com