今天使用uwsgi启动django代码,而后打开浏览器输入http://localhost:8000/admin。后台出现下面错误nginx
invalid request block size: 21573 (max 4096)...skip
我想起来我是使用nginx来把请求发送给uwsgi。因此uwsgi被配置成使用socket方式(为tcp协议)进行通讯。若是打开浏览器访问uwsgi指定的端口,那么浏览器请求uwsgi的方式为http协议,而不是socket方式。因此就致使uwsgi的log文件中打出上面的错误信息。django
若是你想临时使用http访问uwsgi服务。那么须要把以前的uwsgi服务中止,并使用下面命令来启动浏览器
uwsgi --http :8000 --wsgi-file application.py
若是是使用uwsgi.ini配置文件,那么修改里面内容把socket=:8000替换成http=:8000。 而后再次启动uwsgi --ini /patch/to/uwsgi.ini
。app
注意:以上两种方式启动不能混用,例如使用uwsgi --http :8000 --ini /path/to/uwsgi.ini
会形成端口已经被占用的错误:socket
uWSGI http bound on :8000 fd 3 probably another instance of uWSGI is running on the same address (:8000). bind(): Address already in use [core/socket.c line 769]
@完tcp