uwsgi IOError: write error

Alternative solution is to put the following settings in uWSGI config:

ignore-sigpipe = true
ignore-write-errors = true
disable-write-exception = true

See https://github.com/getsentry/raven-python/issues/732


The problem is that clients abort the connection and then Nginx closes the connection without telling uwsgi to abort. Then when uwsgi comes back with the result the socket is already closed. Nginx writes a 499 error in the log and uwsgi throws a IOError.

The non optimal solution is to tell Nginx not to close the socket and wait for uwsgi to come back with a response.

Put uwsgi_ignore_client_abort in your nginx.config.

location @app {
    include uwsgi_params;
    uwsgi_pass unix:///tmp/uwsgi.sock;

    # when a client closes the connection then keep the channel to uwsgi open. Otherwise uwsgi throws an IOError
    uwsgi_ignore_client_abort on;
}

It is not clear if it is possible to tell Nginx to close the uwsgi connection. There is another SO questin about this issues: (Propagate http abort/close from nginx to uwsgi / Django)

Tags:

Nginx

Uwsgi