Ubuntu 17.04下Django Channels集成Redis遇连接错误求助
Let's tackle your problem from two angles: first, getting Redis running without Docker (since that's your immediate need), and then fixing the Docker installation if you still want to use that approach later.
Option 1: Install Redis Directly (No Docker Needed)
This is the simplest way to get Redis up and running for Django Channels on Ubuntu 17.04:
Update your package list
sudo apt-get updateInstall the Redis server package
sudo apt-get install redis-serverVerify Redis is running
By default, Redis starts automatically after installation and listens on port 6379 (exactly what Channels requires). Test the connection with:redis-cli pingYou should get a
PONGresponse if everything's working.Manage the Redis service
- Check status:
sudo systemctl status redis-server - Start if it's not running:
sudo systemctl start redis-server - Set it to start on boot:
sudo systemctl enable redis-server
- Check status:
Confirm Channels Configuration
Make sure yoursettings.pyhas the correct Redis channel layer setup:CHANNEL_LAYERS = { "default": { "BACKEND": "channels_redis.core.RedisChannelLayer", "CONFIG": { "hosts": [("127.0.0.1", 6379)], }, }, }
Once Redis is running, the [Errno 111] Connect call failed error should disappear, since Django Channels can now reach the Redis server on port 6379.
Option 2: Fix Docker Installation on Ubuntu 17.04
If you still want to use Docker for Redis, the issue is that you installed the old/unofficial Docker package from Ubuntu's default repos. Here's how to install the official Docker CE:
Uninstall existing Docker packages
sudo apt-get remove docker docker-engine docker.io containerd runcInstall required dependencies
sudo apt-get install apt-transport-https ca-certificates curl software-properties-commonAdd Docker's official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -Add Docker's official repository
Ubuntu 17.04 uses the codenamezesty, so run:sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu zesty stable"Update package list and install Docker CE
sudo apt-get update sudo apt-get install docker-ceTest Docker works
sudo docker run hello-worldIf you see a welcome message, Docker is installed correctly. Now you can run the Redis command from the tutorial:
sudo docker run -p 6379:6379 -d redis:2.8
内容的提问来源于stack exchange,提问作者Elgin Cahangirov

