OperationalError [WinError 10061] No connection could be made because the target machine actively refused it
I'm trying to send a message to a newly registered user in Django using Redis.
I had a project with the analogical functionality and it worked.
In my current project, I get this error "OperationalError [WinError 10061] No connection could be made because the target machine actively refused it."
I noticed that in that other similar project I had had colorful text of Celery instance's methods (config_from_object and autodiscover_tasks) in VS Code and in the new project they weren't colorful, just a simple text. I thought maybe it was the problem I checked the interpreter and realized it wasn't the one that's in the .venv folder, so I changed it to the .venv interpreter.
app.config_from_object("django.conf:settings")
app.autodiscover_tasks()
The text of the methods became colorful but it didn't solve anything.
I have Docker, Django server and celery run.
I'm using Docker with Redis, I forwared ports when creating the container.
The container is run.
Host is set to 127.0.0.1 in settings.py
settings.py:
EMAIL_HOST = "smtp.gmail.com"
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = "<email>"
EMAIL_HOST_PASSWORD = "<password>"
REDIS_HOST = "127.0.0.1"
REDIS_PORT = "6379"
BROKER_URL = "redis://" + REDIS_HOST + ":" + REDIS_PORT + "/0"
BROKER_TRANSPORT_OPTIONS = {"visibility_timeout": 3600}
CELERY_RESULT_BACKEND = "redis://" + REDIS_HOST + ":" + REDIS_PORT + "/0"
celery.py:
import os
from celery import Celery
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "shop.settings")
app = Celery("shop",
broker_connection_retry=False,
broker_connection_retry_on_startup=True)
app.config_from_object("django.conf:settings")
app.autodiscover_tasks()
I also ran these commands:
Test-NetConnection -ComputerName 127.0.0.1 -Port 6379
docker ps --format "table {{.Names}}\t{{.Ports}}\t{{.Status}}"
1.
ComputerName : 127.0.0.1
RemoteAddress : 127.0.0.1
RemotePort : 6379
InterfaceAlias : Loopback Pseudo-Interface 1
SourceAddress : 127.0.0.1
TcpTestSucceeded : True
2.
docker ps --format "table {{.Names}} \t{{.Ports}} \t{{.Status}}"
NAMES PORTS STATUS
my-redis 0.0.0.0:6379->6379/tcp Up 5 hours
Nothing helped. What else can be the problem?
Thank you for answers in advance