Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uwsgi invalid request block size

Tags:

uwsgi

People also ask

How do I increase the buffer size in uWSGI?

You can increase the buffer size in uWSGI settings. The quick solution would be, Remove cookies from the browser for that URL. Open developer tools in browser > Go to Application tab and > remove cookies associated with the URL.

What is socket in uWSGI?

The http-socket <bind> option will make uWSGI natively speak HTTP. If your web server does not support the uwsgi protocol but is able to speak to upstream HTTP proxies, or if you are using a service like Webfaction or Heroku to host your application, you can use http-socket .


I aslo ran into same issue while following some tutorial. The problem was that I set the option socket = 0.0.0.0:8000 instead of http = 0.0.0.0:8000. socket option intended to be used with some third-party router (nginx for instance), while when http option is set uwsgi can accept incoming HTTP requests and route them by itself.


The correct solution is not to switch to HTTP protocol. You just need to increase the buffer size in uWSGI settings.

buffer-size=32768

or in commandline mode:

-b 32768

Quote from official documentation:

By default uWSGI allocates a very small buffer (4096 bytes) for the headers of each request. If you start receiving “invalid request block size” in your logs, it could mean you need a bigger buffer. Increase it (up to 65535) with the buffer-size option.

If you receive ‘21573’ as the request block size in your logs, it could mean you are using the HTTP protocol to speak with an instance speaking the uwsgi protocol. Don’t do this.

From here: https://uwsgi-docs.readthedocs.io/en/latest/ThingsToKnow.html


I could fix it adding --protocol=http to the uwsgi


I ran into the same issue trying to run it under nginx and was following the docs here. It is important to note that once you switch to nginx you have to make sure you are not trying to access the app on the port specified by the --socket param but rather the "listen" port in nginx.conf. Although your problem is described differently the title matches exactly the issue I had.


This error is shown when uWSGI server is using uwsgi protocol and one tries to access it via http protocol by curl or web browser directly. If you can, try configuring your uWSGI server to use http protocol, so you can access it via web browser or curl.

In case you cannot (or do not want to) change it, you can use a reverse proxy (e.g. nginx) in front of local or remote uWSGI server, see https://uwsgi-docs.readthedocs.org/en/latest/Nginx.html

If it feels like too much work, give a try to uwsgi-tools python package:

$ pip install uwsgi-tools

$ uwsgi_curl 10.0.0.1:3030

There is also a simple reverse proxy server uwsgi_proxy if you need to access your application(s) via web browser etc. See more expanded answer https://stackoverflow.com/a/32893520/179581


As pointed out in another comment from the docs:

If you receive ‘21573’ as the request block size in your logs, it could mean you are using the HTTP protocol to speak with an instance speaking the uwsgi protocol. Don’t do this.

If you are using Nginx, this will occur if you are have this configuration (or something similarly odd):

proxy_pass http://unix:/path/to/socket.sock

this is speaking HTTP to uWSGI (which makes it grumpy). Instead, use:

uwsgi_pass unix:/path/to/socket.sock;

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!