I am able to run redis locally and everything works.
However when I deploy to heroku I get this error:
Error 111 connecting to localhost:6379. Conn
Right now Heroku automatically sets the environment variable REDIS_URL to URL + port.
A convenient way to work with redis on heroku is to use a connection pool:
settings.py
import redis
REDIS_DEFAULT_CONNECTION_POOL = redis.ConnectionPool.from_url(os.getenv('REDIS_URL', 'redis://localhost:6379/'))
whererver.py
from redis import Redis
from myProject.settings import REDIS_DEFAULT_CONNECTION_POOL
redis = Redis(connection_pool=REDIS_DEFAULT_CONNECTION_POOL)
print(redis.keys()) # works