Error 111 connecting to 127.0.0.1:6379 + Channels redis + django
Submitted by stephenwenceslao on Sat, 08/26/2023 - 16:28sudo apt install redis-server
sudo systemctl restart gunicorn_app
sudo apt install redis-server
sudo systemctl restart gunicorn_app
sudo usermod -aG username www-data
sudo nginx -t && sudo systemctl restart nginx.service
python manage.py makemigrations account
python manage.py migrate
I have spent so many hours just to figure this out. I use wss(secure) for my django websocket. Ive realized that using firebase and firecamp is working perfectly, but in my flutter app websocket connect it does not work. arggg, spending many hours working this error (I initially dont know why the heck is this).
Adding this piece of code in the main.dart file fix my issue. :)
Add this line of code inside your stream listen function, under initState.
using AsyncWebcocketConsumer to add database access instead of using WebsocketConsumer, this is base on the channels tutorial.
Version:
django == 4.0.3 channels == 3.0.4
Important notice: must declare first before, AuthMiddlewareStack.
import os import django os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myapp.settings') django.setup() from channels.auth import AuthMiddlewareStack
1.Add middleware.py in your django app.
must allow whatever port you set
1.Can run gunicorn on your env
gunicorn --bind 0.0.0.0:9001 myapp.wsgi2.Added subdomain on droplet networking. 3.Root access. 4.Install certbot nginx
sudo apt install certbot python3-certbot-nginx.
1.Make sure you already installed the gunicorn on your django env
pip install gunicorn
2.Create new socket file on
sudo nano /etc/systemd/system/gunicorn_subdomain1.socket
Need to restart application from namecheap cpanel to take effect the changes from
models.py.
python manage.py makemigrations
python manage.py migrate