简体   繁体   中英

Redis django connects to localhost redis, even when I change URL and PORT

return {
            'BACKEND': 'django_redis.cache.RedisCache',
            'LOCATION': f'redis://{self.REDIS_URL}:{self.REDIS_PORT}',
            'OPTIONS': {
            'CLIENT_CLASS': 'django_redis.client.DefaultClient',
        }

this is my redis code to put in CACHES, still even after specifying different redis_url and port, connects to localhost 127.0.0.1:6379

I want to connect to a different IP url and PORT.

I tried different 'BACKENDS' and CLIENT_CLASS and pools, playing around with different CACHES types. I can connect to my url-port redis using this:

return redis.StrictRedis(host=self.REDIS_URL, port=self.REDIS_PORT, db=0, decode_responses=True, encoding="utf-8")

but not when I want to setup CACHES.

I solved all my redis problems by switching to rabbitmq. I suggest you do the same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM