Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

508
Vistas
Django channels would not start redis server using CHANNEL_LAYERS

I am trying to replicate Mikhail Andreev chat with Django channels posted here: https://gearheart.io/blog/creating-a-chat-with-django-channels/

and when I run the server: $ python3 ./manage.py runserver the redis server does not start. Here is the full message:

 Performing system checks...

 System check identified no issues (0 silenced).
 April 27, 2017 - 20:59:01
 Django version 1.10.3, using settings 'multichat.settings'
 Starting Channels development server at http://127.0.0.1:8000/
 Channel layer default (asgi_redis.core.RedisChannelLayer)
 Quit the server with CONTROL-C.
 2017-04-27 20:59:01,278 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.receive
 2017-04-27 20:59:01,279 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.receive
 2017-04-27 20:59:01,282 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.receive
 2017-04-27 20:59:01,282 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.receive
 2017-04-27 20:59:01,283 - INFO - server - HTTP/2 support not enabled (install the http2 and tls Twisted extras)
 2017-04-27 20:59:01,283 - INFO - server - Using busy-loop synchronous mode on channel layer
 2017-04-27 20:59:01,284 - INFO - server - Listening on endpoint tcp:port=8000:interface=127.0.0.1
 2017-04-27 20:59:01,294 - ERROR - server - Error trying to receive messages: Error 61 connecting to localhost:6379. Connection refused.
 Exception in thread Thread-1:
 Traceback (most recent call last):
   File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 439, in connect
     sock = self._connect()
   File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 494, in _connect
     raise err
   File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 482, in _connect
     sock.connect(socket_address)
 ConnectionRefusedError: [Errno 61] Connection refused 

I can solve it by running redis server from a different terminal, however that is what Django Channels supposed to do in the settings:

redis_host = os.environ.get('REDIS_HOST', 'localhost')
# Channel layer definitions
# http://channels.readthedocs.org/en/latest/deploying.html#setting-up-
a-channel-backend
CHANNEL_LAYERS = {
    "default": {
        # This example app uses the Redis channel layer implementation asgi_redis
    "BACKEND": "asgi_redis.RedisChannelLayer",
    "CONFIG": {
        "hosts": [(redis_host, 6379)],
    },
   "ROUTING": "multichat.routing.channel_routing", # We will create it in a moment
    },
}

Appreciate any help and advice.

Many thanks!

about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

See https://github.com/django/daphne#http2-support

You should install Twisted pip install -U Twisted[tls,http2]

about 4 years ago · Santiago Trujillo Denunciar

0

Django Channels will not automatically start Redis. Redis is a separate service, which should be already running on your machine or elsewhere. Channels relies on Redis for its backend as message broker.

From Redis:

Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker.

You need to follow the Installation instructions for Redis and start it using:

$ /path/to/redis-server

Your Django app should also be properly configured to use Redis. You will also need asgi_redis package installed in your Python virtual environment, if you use one.

As you can see from the error messages you have pasted, Django Channels couldn't connect to localhost:6379, because Redis is likely not running.

2017-04-27 20:59:01,294 - ERROR - server - Error trying to receive messages: Error 61 connecting to localhost:6379. Connection refused. 
  Exception in thread Thread-1: 
  Traceback (most recent call last):
    File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 439, in connect 
      sock = self._connect() 
    File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 494, in _connect 
      raise err 
    File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 482, in _connect 
      sock.connect(socket_address) 
  ConnectionRefusedError: [Errno 61] Connection refused

UPDATE (2019-02-26):

asgi_redis package is for Channels 1.x, whereas for Channels 2.x, one will need channels_redis.

about 4 years ago · Santiago Trujillo Denunciar

0

I think you have installed redis channel in virtualenv. I was facing the same issue then I have installed redis in my local too and then it works fine. You will see the Services(local) find there Redis Server.

For redis installation, you can follow this link for ubuntu: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-18-04

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda