The environment:

  • Fresh install of Ubuntu 16.04 on a 256MB VPS
  • LEMP stack with PHP 7.1
  • Latest WordPress install with Avada theme & associated plugins only.
  • At least 75MB of RAM free when not uploading

The error:

  • Getting 502 errors when uploading large images ~8MB and 24MP. The server receives the file okay, but returns the error when processing thumbnails.
  • I used this server to explore possible self-hosting image solutions, so I also installed Lychee temporarily, and the same situation occurs when uploading images.

Nginx Log:

recv() failed (104: Connection reset by peer) while reading response header from upstream,

PHP7.1-FPM Log:

[pool www] child 451 exited on signal 9 (SIGKILL)

Nginx Config: https://pastebin.com/MtWdeeGz

Nginx Site Config: https://pastebin.com/YqWg9Euy

PHP.ini - pastebin.com/cJpgchQj

Things I've tried but no avail:

  • Used sockets instead of TCP
  • Implemented fast_cgi params in both the nginx.conf and the site config
  • Increased WordPress memory limit in wpconfig.php
  • Increased PHP memory limit in PHP.ini
  • Increased execution time

Thanks for any help and insight that you can provide!


There is not enough information in question, but I think your php-fpm process killed by OOM-killer during thumbnail processing. You could check it by command dmesg | grep kill. There is two way to solve this issue, increase RAM or add swap, see instruction there.

| improve this answer | |
  • Thanks! OOM was killing my PHP processes. My provider won't permit addition of swap, so I guess I'll have to find a different path. – Titan May 14 '17 at 1:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.