由于正在使用 gunicorn 连接,heroku 本地网络无法正常工作

heroku local web doesn't work because of gunicorn connection in use

我已经克隆了这个 heroku-django-starter https://github.com/heroku/heroku-django-template

我已经完成了pip install gunicorn

当我 运行 heroku local web 时,我收到以下错误日志。

forego | starting web.1 on port 5000
web.1  | [2016-03-08 21:03:59 -0800] [8288] [INFO] Starting gunicorn 19.4.5
web.1  | [2016-03-08 21:03:59 -0800] [8288] [ERROR] Connection in use: ('0.0.0.0', 5000)
web.1  | [2016-03-08 21:03:59 -0800] [8288] [ERROR] Retrying in 1 second.
web.1  | [2016-03-08 21:04:00 -0800] [8288] [ERROR] Connection in use: ('0.0.0.0', 5000)
web.1  | [2016-03-08 21:04:00 -0800] [8288] [ERROR] Retrying in 1 second.
web.1  | [2016-03-08 21:04:01 -0800] [8288] [ERROR] Connection in use: ('0.0.0.0', 5000)

此答案假设您 运行正在使用 *nix 机器,例如 OSX 或 Linux。

kill `lsof -i :5000`

这样做是终止端口 5000 上的 运行ning 进程。如果您想查看端口 5000 运行ning 上的内容,您还可以执行以下操作:

ps aux | grep 5000

这将向您显示匹配字符串 5000 的进程 运行ning,您可能会看到导致该错误的原因。然后,您可以 kill 该进程 ID。

另一种选择是 运行 您的应用程序在不同的端口上,如下所示:heroku local web --port 5001