You need to identify where the request producing the original error was processed. ‘Upstream’ might be a lot of different things (proxy, fastcgi, uwsgi).
You need to tweak the proper upstream *_buffers and *_buffer_size to make the proper buffer(s) bigger.
You can set the following values and test if it works. If it doesn’t work you can manually increase the value to 64k, 128k, 256k, and 512k. And then reload nginx.
*_buffers 16 32k;
*_buffer_size 64k;
*_busy_buffers_size 64k;