WordPress “HTTP error” on large image file upload

Last updated on

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:

/var/log/nginx/error.log
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:

/var/log/php7.0-fpm.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. 

Let me know in the comments if this helped. Follow me @DevAnswers or read more.

1 Star2 Stars3 Stars4 Stars5 Stars 5.00 (2 votes)

Feedback

Your email address will not be published. Required fields are marked *

We use Markdown to style comments, like on Github and Reddit.
To do a line break, type two spaces after the sentence.
You can add inline code by wrapping it in backticks: `code here`

    To do an entire block of code  
    type four spaces before the line
    and it will appear in a block like this.
    <-- four empty spaces

1 reply

Thank you very much! I have already tried not to change it in the parameters. Your article helped)