I have a very simple application with python and redis where python code sends numbers to the redis server using redis-py package. The application works perfectly while deployed on my local machine via docker compose.
The issue arises when I deploy the same application to AWS ECS cluster as an ECS service. AWS connects between ECS services using a method called "service connect".
For showing the error message easily, I will paste the screenshot of connecting via redis-cli from inside the python docker container instead of python tracebacks.
The error message is as follows:
error
I have checked the following:
Ensured that port 6379 is open from python container
Hostname "celeryredis" is running a redis server and the python container is able to access it.
telnet
ping
Redis-server is not authenticated. But I have tried setting a password to the redis server and while connecting to it from the python code still raises the issue.
I have also tried by explicitly setting the protocol via: r = redis.from_url("redis://celeryredis:6379/0")
I have tried using awsvpc network mode in AWS and the issue persists.
I have ensured that we are using tcp protocol.
I have tried to use --loglevel as debug. But it does not show any connected clients.
When connected from a python terminal, I am getting a 400 Bad request.
redis-py-error
I expect to get "OK" when I run ping() from the redis-cli