[Troubleshooting] docker 상에서 redis가 정상적으로 연결되지 않는 문제
[Troubleshooting] docker 상에서 redis가 정상적으로 연결되지 않는 문제
🚫 현상
1
2
3
4
5
6
...
dev-backend | connection.connect()
dev-backend | ~~~~~~~~~~~~~~~~~~^^
dev-backend | File "/usr/local/lib/python3.13/site-packages/redis/connection.py", line 363, in connect
dev-backend | raise ConnectionError(self._error_message(e))
dev-backend | redis.exceptions.ConnectionError: Error 111 connecting to 127.0.0.1:6379. Connection refused.
💡원인
🛠 해결책
1
2
3
4
5
6
7
8
9
from redis import Redis
from fastapi import HTTPException
from twilio.rest import Client
import random
import os
# Redis 설정
redis_client = Redis(host=**"redis"**, port=6379, db=0, decode_responses=True)
...
🤔 회고
📚 Reference
This post is licensed under CC BY 4.0 by the author.