在 pythonanywhere 上托管使用 redis 的 Django 项目

Pil*_*ila 1 django redis pythonanywhere

我在本地笔记本电脑上开发了一个电子商务网站,该项目使用了redis当我从本地主机运行该项目时,它使用以下命令完美运行 r = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB)

REDIS_HOST = 'localhost'
REDIS_PORT = 6379
REDIS_DB = 1
Run Code Online (Sandbox Code Playgroud)

现在,我正在尝试将项目部署到任何地方的 python 上。我已经安装了redis并启动了服务器,更改localhostmyhost.pythonanywhere.com但是当我运行访问该站点时出现以下错误:

Error 111 connecting to 50.19.109.98:6379. Connection refused.
Request Method: GET
Request URL:    http://myhost.pythonanywhere.com/en/4/black-garbage-t-shirt/
Django Version: 1.8.3
Exception Type: ConnectionError
Exception Value:    
Error 111 connecting to 50.19.109.98:6379. Connection refused.
Exception Location: /home/dguy/dguy/venv/lib/python3.4/site-packages/redis/connection.py in connect, line 436
Python Executable:  /usr/local/bin/uwsgi
Python Version: 3.4.3
Python Path:    
['/var/www',
 '.',
 '',
 '/var/www',
 '/home/dguy/dguy/venv/lib/python3.4',
 '/home/dguy/dguy/venv/lib/python3.4/plat-x86_64-linux-gnu',
 '/home/dguy/dguy/venv/lib/python3.4/lib-dynload',
 '/usr/lib/python3.4',
 '/usr/lib/python3.4/plat-x86_64-linux-gnu',
 '/home/dguy/dguy/venv/lib/python3.4/site-packages',
 '/home/dguy/dguy',
 '/home/dguy']
Server time:    Wed, 17 Aug 2016 16:10:56 +0100
Run Code Online (Sandbox Code Playgroud)

有人可以帮帮我吗。什么是正确的配置。

Gle*_*enn 5

Redis 不适用于 PythonAnywhere。

  • Redis Labs 在这里提倡:任何 us-east 实例都可以(你的 us-east-1c 和我的 us-east-1c 不一定相同:https://support.redislabs.com/hc/en-us/articles /202932038-您为什么推荐在 AWS 上映射我的可用区-) (4认同)
  • PythonAnywhere 开发人员在这里:我们的网站不支持保持 Redis 服务器运行所需的“长时间运行”进程(尽管我们正在努力改变这一点)。但如果您有付费帐户,则可以访问外部 Redis 提供商,例如 Redis Labs。如果您在 Amazon 的 us-east-1c 数据中心配置您的 Redis 实例,那么您将位于我们的服务器旁边,因此延迟将是最小的。 (2认同)