I am trying to run a redis server for task queues. It works on my local laptop but when I port it to a virtual machine (CentOS) it gives me this error:
redis.exceptions.ConnectionError: Error -3 connecting to redis:6379. Temporary failure in name resolution.
I looked it up and there are no threads with this specific error. Doesn't seem like anyone has encountered it? My code snippet is like:
redis_url = current_app.config['REDIS_URL']
with Connection(redis.from_url(redis_url)):
q = Queue()
task = q.enqueue(upload_data_to_ES, args=(data,), job_timeout=150, result_ttl=1000)
The only major difference is that I set the docker-compose.yml file to have network_mode: "host" so that it can communicate with an elastic search server on the virtual machine. Would this cause the issue? I don't know how they are related. Help would be greatly appreciated.
My docker-compose.yml file looks like this:
version: '3.7'
services:
gilsonapp:
build: .
network_mode: "host"
image: gilsonapp:latest
container_name: gilsonapp
ports:
- 8003:8003
command: python app.py
volumes:
- ./app:/usr/src/app
- /test_files:/usr/src/app/mnt/tsl_files
environment:
- FLASK_DEBUG=1
- FLASK_ENV=testing
- REDIS_URL="redis://redis:6379/0"
env_file:
- oracle_env_vars
working_dir: /usr/src/app
depends_on:
- redis
worker:
image: gilsonapp
container_name: gilsonapp_worker
command: python worker.py
volumes:
- ./app:/usr/src/app
working_dir: /usr/src/app
environment:
- REDIS_URL="redis://redis:6379/0"
- APP_SETTINGS=config.TestingConfig
depends_on:
- redis
redis:
image: redis:alpine
expose:
- '6379'