connect() failed (111: Connection refused) while connecting to upstream
报错
Nginx代理Vue项目,访问基于Flask搭建的后台时,一直报出访问路径错误。查看Nginx错误日志,发现报错是connect() failed (111: Connection refused) while connecting to upstream 。
$ cat /var/log/nginx/error.log
2022/04/26 17:46:26 [error] 1593845
原因
原因是在安装flask 的时候,使用时是apt 安装的,而不是pip3 进行安装的。
$ sudo apt install python3-flask
$ flask run -h 0.0.0.0 -p 5000
解决方案
卸载掉python3-flask 。
$ sudo apt remove python3-flask
使用pip3 安装flask 。
$ pip3 install flask
WARNING: The script flask is installed in '/data2/jing.w/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
$ sudo ln -s /data2/jing.w/.local/bin/flask /usr/bin/flask
|