Wordpress upload: HTTP Error

I set up a Wordpress site with Caddy and it was successful, environment Ubuntu 18.04, + Wordpress 5.2, + Caddy 1.0.0 + PHP 7.0 + MySQL 5.7.
But when I tried to upload a video, it shows HTTP error. the file size is 29M. There’s no issue when i tried to do that with file less than 10M.

I’ve modified the below items in php.ini, but it’s not working.
upload_max_filesize = 1024M
post_max_size = 1024M

I know there is “client_max_body_size” in nginx setting to modify the max body size, and also tried to set the similar thing in Caddyfile. But it still won’t work. Can anybody help me on that?

My Caddyfile as below:

https://example.com {
tls example@gmail.com
root /var/www/wordpress

fastcgi / /run/php/php7.0-fpm.sock php

rewrite {
r /uploads/(.*).php
to /

rewrite {
if {path} not_match ^/wp-admin
to {path} {path}/ /index.php?{query}

limits {
body /upload 100mb

http://example.com {
redir https://example.com{url}

Hi @musk, welcome to the Caddy community!

Add the log and errors directives to your Caddyfile, reload Caddy, reproduce the error again by attempting an upload, and then post the contents of the log/error files.


Thanks @Whitestrake, below are my errors log. When I found it was timeout related issue, I tried to modify my php.ini from max_execution_time = 30 to max_execution_time = 300, and restarted the php7.0 service, but it’s still not working.

19/May/2019:19:40:16 -0400 [ERROR 504 /wp-admin/async-upload.php] read unix @->/run/php/php7.0-fpm.sock: i/o timeout

19/May/2019:19:48:15 -0400 [ERROR 504 /wp-admin/async-upload.php] read unix @->/run/php/php7.0-fpm.sock: i/o timeout

Try adjusting Caddy’s timeouts to higher values or to 0 at first to confirm they are the issue:

@magikstm, I’ve tried that: timeouts 0, but the problem is still there.

Hmm, not a lot of help in those logs, unfortunately.

Can you check the PHP-FPM error log? It should / can be configured in the PHP www.conf file.

@Whitestrake, I enabled that as the attached, but no error found yet. Let me know if I’m doing wrong.

There is another log as the attached. I can’t find any useful info either. My file path is: /var/log/php7.0-fpm.log

Ahh, that’s unfortunate…

Well, we should probably at least try to find out whether it’s an issue on the PHP-FPM side or the Caddy side. Are you able to configure nginx to temporarily replace Caddy and see if the error still occurs?

@Whitestrake, I have the nginx which is doing good, as I can set “client_max_body_size =500m” in nginx.conf to unlimit it.
I want to transfer all nginx to Caddy because it’s so handy. From the caddy errors log I believe it’s php7.0 related timeouts issue, but have no idea where to find and correct it.

I also tried different VPS with different Linux distribution such as Debian 9, Ubuntu 18.04, and same issue happened.

Not sure if anybody can set up a Wordpress with Caddy as what I did, and see if there’s similar issue of uploading.

Caddy Errors Log:
[ERROR 504 /wp-admin/async-upload.php] read unix @->/run/php/php7.0-fpm.sock: i/o timeout

OK, yeah, I think I got it.

  • read_timeout is the time allowed to read a response from the backend. Must be a duration value. Default 60s.
  • send_timeout is the time allowed to send a request to the backend. Must be a duration value. Default 60s.


First I tried just setting send_timeout. That fixed it stopping mid-upload, but I found that as soon as the POST finished (100% upload), it would 504 again. That’s because the sum request time had already exceeded the read_timeout.

Setting both to 600s allowed me to upload any filesize up to the PHP-set limits, as long as the transfer was finished under ten minutes.

My final Caddyfile:

wordpress.example.net {
  root /srv/wordpress
  fastcgi / php:9000 php {
    read_timeout 600s
    send_timeout 600s
  rewrite {
    to {path} {path}/ /
1 Like

@Whitestrake, Yeah! I think this is the correct solution. It’s working! Thank you very much for your help.

1 Like

No worries! :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.