Hello,
Someone can help me?
I have this error after the deployment of my API on Koyeb.
Exception Value: Error -2 connecting to cfa-redis-prod:6379. Name or service not known.
My Docker Compose file contains two services: API and Redis. Our API requires a connection to the Redis service in order to function properly.
In the first service, i’m using the variable : REDIS_DB: redis://cfa-redis-prod:6379/0
Here is my docker-compose.yml content :
version: “3.8”
services:
cfa-api-prod:
container_name: cfa-api-prod
image: cfa-api-prod
build:
context: .
dockerfile: ./docker/Dockerfile
restart: on-failure
ports:
- ${PROD_PORT}:8000
env_file:
- .env
environment:
LAUNCH_TYPE: webserver
DB_HOST: ${DB_HOST}
DB_USER: ${DB_USER}
DB_PASSWORD: ${DB_PASSWORD}
DB_NAME: ${DB_DATABASE}
DB_PORT: ${DB_PORT}
REDIS_DB: redis://cfa-redis-prod:6379/0
CELERY_BROKER_URL: redis://cfa-redis-prod:6379/1
DB_ENGINE: django.db.backends.postgresql
depends_on:
- cfa-redis-prod
command: >
bash -c "
python3 manage.py makemigrations django_cron &&
python3 manage.py migrate &&
python3 manage.py collectstatic --noinput &&
gunicorn SpectorlyAPI.wsgi:application -w 3 -b 0.0.0.0:8000 --reload"
networks:
- cfa_network_prod
cfa-redis-prod:
image: redis:latest
container_name: cfa-redis-prod
ports:
- 6379:6379
env_file:
- .env
volumes:
- redis_data:/data
networks:
- cfa_network_prod
volumes:
postgres-data:
redis_data:
networks:
cfa_network_prod:
driver: bridge