Django + React + Regis - Find BUG in my code to run in DOCKER -- 4

Job ID: 32676883

Budget: $10 – $30 USD

Hi, I'm trying to run my React + Django + Regis with docker and I'm having an error. It works outside of docker but when in docker it doesn't work. The only thing you need to do is to edit configuration to get it to connect to chat when I run it with docker as it would when run outside of docker

Note: I'm using django channels to use chat functionality which requires regis to run

What does work?
- Able to connect to http://localhost to access frontend
- Able to connect to http://localhost:8000 to access backend

What doesn't work?
- WebSocket connection to 'ws://127.0.0.1:8000/ws/chat/undefined/' failed:

I think this has to do with regis not running/setup properly inside the docker containers, because when running it outside of docker it works perfectly by starting regis this way

docker run -p 6379:6379 -d redis:5

https://channels.readthedocs.io/en/stable/tutorial/part_2.html


Django Settings.py

CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
"hosts": [('redis', 6379)],
},
},
}
Related categories: Django React.js Docker