question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Django channels would not start redis server using CHANNEL_LAYERS

See original GitHub issue

I am trying to replicate 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!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

26reactions
abhannancommented, Apr 2, 2018

I used following for mac with homebrew to make it work:

brew install redis

and then:

brew services start redis

21reactions
rahul6612commented, Mar 17, 2018

to start the Redis Server

  1. install redis from here https://github.com/rgl/redis/downloads
  2. open task manager and go to services
  3. in services find redis
  4. right click on redis and choose open services
  5. a window will pop and you will see the Services(local) find there Redis Server
  6. now click on start
Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Django channels would not start redis server using ...
Channels relies on Redis for its backend as message broker. From Redis: Redis is an open source (BSD licensed), in-memory data structure store, ......
Read more >
Channel Layers — Channels 4.0.0 documentation
Channel layers are configured via the CHANNEL_LAYERS Django setting. ... The layer uses Redis as its backing store, and it supports both a...
Read more >
Installing Django Channels 2 (Redis and WebSockets)
Watch the course: https://codingwithmitch.com/courses/r... Installing django channels 2 into your django project. This project uses Redis ...
Read more >
Channels Documentation - Read the Docs
A Channels routing configuration is an ASGI application that is similar to a Django URLconf, in that it tells Channels what code to...
Read more >
Introduction to Django Channels - TestDriven.io
This tutorial shows how to use Django Channels to create a real-time ... Here, we let channels_redis know where the Redis server is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found