Channel layers and redis connectivity in Docker.

Hello Everyone,
I am trying to connect to redis which is running on locally(WSL) to the Django application in Docker
but i am always getting error like this

ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 6379)

and i am performing this steps to check the connectivity

# >>> import channels.layers
# >>> channel_layer = channels.layers.get_channel_layer()
# >>> from asgiref.sync import async_to_sync
# >>> async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'})
# >>> async_to_sync(channel_layer.receive)('test_channel')

this is my settings.py config

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels_redis.core.RedisChannelLayer",
        "CONFIG": {
            "hosts": [("127.0.0.1", 6379)],
            # "hosts": [("redis", 6379)],
        },
    },
}

What other steps do I need to follow for connectivity to ensure that I can connect in Django.?

Is redis and your Django docker both running in the same WSL instance?

Is this WSL 1 or 2?

Have you verified that redis is available by connecting with the redis-cli ?

YES

2

  NAME                   STATE           VERSION
* Ubuntu-22.04           Running         2
  docker-desktop         Running         2
  docker-desktop-data    Running         2
pranith_dev@DESKTOP-FKFB7O2:/mnt/c/Users/user/Desktop/Datavoice/snowbell/Cartonprinting/cp-distributed/cp-distributed$ sudo service redis-server start      
pranith_dev@DESKTOP-FKFB7O2:/mnt/c/Users/user/Desktop/Datavoice/snowbell/Cartonprinting/cp-distributed/cp-distributed$ redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>

I Figured out a way to resolve this issue by adding redis in docker-compose.yml file and connecting to the django using redis running on docker.
Below config establishes a connection with django.

 "hosts": [("redis", 6379)],

But i want to connect locally to utilise my ram on pc and i have tried with these ip address in channels_layers settings

- Ethernet adapter vEthernet (Default Switch): 172.24.176.1
- Ethernet adapter vEthernet (WSL): 172.25.80.1
- Ethernet adapter Ethernet: 192.168.1.111

You are. What makes you think that it’s not?

Earlier, I was unable to connect to Redis, which was running on Docker. That’s why I mentioned that point. Are there any resources that I need to check out?

I’m not sure I’m understanding you here.

You wrote:

I read this as saying that you have it working. Is that correct?

If so, what’s the issue needing to be resolved?

I have mentioned here.

And that’s what I was asking - what makes you think you’re not using ram on your pc?

I think you’re worrying about something that isn’t an issue.