報錯解決——uwsgi錯誤invalid request block size

uwsgi錯誤invalid request block size

  使用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

 

注意:以上兩種方式啓動不能混用,例如使用uwsgi --http :8000 --ini /path/to/uwsgi.ini會形成端口已經被佔用的錯誤:app

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]
相關文章
相關標籤/搜索