I ran into a problem with WordPress on my DigitalOcean droplet recently. When uploading files larger than 10MB, WordPress would return a HTTP Error and fail to generate the thumbnail, although it did actually upload the file.
Checking the Nginx error log I saw:
2017/05/05 23:11:48 [error] 2755#2755: *5 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 80.13.XX.XX, server: 178.62.XX.XX, request: "POST /wp-admin/async-upload.php HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "178.62.XX.XX", referrer: "http://178.62.XX.XX/wp-admin/post.php?post=1232&action=edit"
And the PHP-FPM error log:
[06-May-2017 23:12:00] WARNING: [pool www] child 9242 exited on signal 9 (SIGKILL) after 149.853930 seconds from start
I monitored the system processes during file upload to see if there was a resources issue and sure enough it showed the memory usage peaking when WordPress tried to generate the thumbnail. There wasn’t enough RAM on my 512MB DigitalOcean droplet to carry out the request.
Instead of upgrading the droplet to more RAM, I instead created a 1GB swap file which resolved the issue. Here’s the guide for creating a swap file on Ubuntu 16.04.
p.s. I increased my AdSense revenue by 68% using AI 🤖. Read my Ezoic review to find out how.