This all began with a “Server Error 400” when updating a page in Elementor. So, naturally I searched for “Server Error 400 Elementor”.
I searched the whole day in forums for a solution to this. I tried everything that all the code experts suggested, that apparently helped others. None of them worked for me. In the end, when I ran out of solutions in the forums, and was at the point of tearing my hair out and dangerously close to chucking my laptop out of the window, I decided to try something actually quite simple. But first things first. Let me take you through the process because one of these might just be the solution for you.
What is Server Error 400?
So, what exactly is “Server Error 400”? A 400 Bad Request Error indicates that the server (remote computer) is unable to process the request sent by the client (web browser), due to an issue that is perceived by the server to be a client problem. Well, I certainly knew I had a communication problem here.
The first thing I checked was to see if this was happening to my other sites so that I could pinpoint the source of the issue. My other sites were okay. I also eliminated the browser as being the source of the problem by opening WordPress and Elementor on other browsers. Still the same problem.
Some forums also suggested an http/https issue. I considered this possibility as I had already had some problems with Mixed Content not too long ago which I had already solved. See my blog post on “SSL Certificate displaying Mixed Content“. Others claimed it was a Windows issue.
Flush your local DNS cache
The first thing I tried was to flush my local DNS cache. Flushing the DNS resolver cache can help resolve DNS related problems in Microsoft Windows. Issues would include web site not found errors or not being able to view certain web pages that have changed. It was worth a shot. This is how you do it:
For Windows 10:
Click on Start (Windows Logo). In the Search field type in “cmd”. The Command Prompt will reveal itself. On the right choose Run as Administrator.
ipconfig /flushdns then press “Enter“. (make sure there is a space before the slash)
You should now see the following confirmation message: “Successfully flushed the DNS Resolver Cache.”
This did not work for me, but it could be a solution for you.
I then decided to try and install W3 Total Cache as this was a possible solution. To my dismay and horror, WordPress presented me with an error window “Update Failed: The package could not be installed. PCLZIP_ERR_MISSING_FILE”.
When installing or updating a plugin, theme or WordPress core, WordPress needs to create a temporary folder to put the files in when downloading during the installation process. It will do this in C:\WINDOWS\TEMP. If WordPress detects that it cannot write files to this temp directory, then you get the error message like “The package could not be installed. PCLZIP_ERR_MISSING_FILE: Missing archive file ‘C:\WINDOWS\TEMP/akismet.tmp ”, or this error message “Installation failed: Destination directory for file streaming does not exist or is not writable.”
Quickly check to see if the file permissions are correctly set to 755 in your wp-content file. You can do this by FTP access in FileZilla (or if your hosting provides a File Manager utility, use that). Open FileZilla and find your wp-content file (It should be in the root folder). Right-click and choose “File Attributes”. A window will open allowing you to check and edit the file permissions.
Define the absolute path
If that hasn’t fixed your problem, you will need to define the absolute path of the temp folder in your WordPress by adding a snippet of code to the wp-config.php file .
- Open FileZilla (or C-Panel). Connect to your website files. You need to find the wp-config.php file which is in the root folder. The code you need to change is in this file. You can do this in 2 ways:
- You can either download the wp-config.php file, or
- you can edit the php file within FileZilla. I prefer to download just in case I botch it up. In which case, I still have the original unchanged file as a safety net.
- Download the wp-config.php file (just drag and drop within the FileZilla screen from the server files to your local download folder). Make a copy of it and rename both files so that the “copy” (the one you are about to edit) now has the name “wp-config.php”.
- Open this in any program that can read PHP files. Notepad in Windows is one example of a PHP file opener, but syntax highlighting is so helpful when coding in PHP that a more dedicated PHP editor is usually preferred. Here is a handy link on PHP with some tips on which program to use when editing code. https://www.lifewire.com/php-file-4138559
- In the PHP file, search for (CTRL-F) the following code.
if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/');
- Now add the following line of code after that:
/*Set WordPress temporary directory */ define('WP_TEMP_DIR', ABSPATH . 'wp-content/temp');
- When you are ready to close your edited file, save it and upload it back into your server files. Overwrite if FileZilla prompts you.
- Create a temp folder within wp-content simply called “temp”.
The code that you add after this varies depending on which forum thread you read, and any one of them could work for you so I will list them here:
/* Setup a temporary folder for uploading and updating */
define( ‘WP_TEMP_DIR’, ABSPATH . ‘wp-content/tmp/’) ;
You may have to create a “tmp” folder within wp-content for this to work
/* Setup a temporary folder for uploading and updating */
define( ‘WP_TEMP_DIR’, ABSPATH . ‘wp-content/uploads/’) ;
You should not have to create an uploads folder.
This is the one that worked for me:
The “temp” did not work for me. I did all of the above but to no avail. So I decided to try this:
if ( !defined('ABSPATH') ) define('ABSPATH', dirname(FILE) . '/'); /*Set WordPress temporary directory */ define('WP_TEMP_DIR', ABSPATH . 'wp-content/');
Note that if the temp directory is defined otherwise further down in the wp-config.php file, the later definition must either be changed to the above, or deleted. The later definition will override the earlier one.
This solved both the plugin download issue and updating in Elementor.