WordPress – Unexpected response from the server Fixed

Unexpected response from the server

unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page.

If you’re seeing this error and dont know how to tackle it, I have a solution for you right here in this post.

There are a couple of settings we are going to change on our php.ini file and an additional rule we are going to add to our Nginx Site Configuration.

If you dont have access to these files, you should contact your hosting company and asked them to configure these stuffs for you.

Configuring php.ini file

Open your php.ini file and change the following lines to these values.

php.ini file lives here /etc/php/7.4/fpm

Run this code to open php.ini

sudo nano /etc/php/7.4/fpm/php.ini
upload_max_filesize = 256M
max_file_uploads = 256M
memory_limit = 256M
post_max_size = 500M
Hint: use Ctrl + w on your keyboard to find.

See Also

Solution – 502 Bad Gateway on Homestead

Solution – The guest machine entered an invalid state

Post-Processing of the Image Failed – WordPress Easy fix

Configure Nginx Site configuration

The above php configuration might be a reason you’re having this error but in my case, adding this line to my nginx site configuration is what fixed it.

Your nginx file lives here /etc/nginx/sites-available

sudo nano /etc/nginx/sites-available/yoursite

Once open add the following directive to set the maximum allowed size in HTTP(server/location) section

client_max_body_size 10M;

After adding it you’re nginx configuration should now look like this

server {
        listen 80;
        root /var/www/yoursite.com/public;

        index index.php index.html index.htm index.nginx-debian.html;
        server_name yoursite.com;

        client_max_body_size 10M;

        location / {
                #try_files $uri $uri/ =404;
                 try_files $uri $uri/ /index.php$is_args$args;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }

        location = /favicon.ico { log_not_found off; access_log off; }
        location = /robots.txt { log_not_found off; access_log off; allow all; }
        location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
                expires max;
                log_not_found off;
        }
}

If this solution helped you resolved your problem please dont hesitate to share this article, someone outthere may be in need of it too. Thanks

All you need to know about Loans | Best Loans offers Best Laravel Guide | Code Best vue.js tutorials || Latest Practical Vue Js Tutorials Covid-19 Cross River News Update | Novel Coronavirus insurance Laragon Laravel Tutorials Simple to Advance Latest Amazon Technologies || List of all Amazon Technologies Latest Educational News Latest Job Opportunities News | All Recruitment News latest news from Google | Browse Google latest info Latest Technology News || Trending Technologies Latest Waec News and Info Nigeria Customs Service Trailers

1 Trackback / Pingback

  1. Laravel Project Shows index of / » Sleettech

Leave a Reply