"...highly cost effective."
— Alexander Sawyer What They Say

WordPress Update Error: Failed to write request to temporary file

One of the WordPress plugins I use on two sites had an update. On the first site, it updated fine as always. On this site (which is hosted on a different server), the plugin update failed with an error message that I had not seen until today.

An error occurred while updating Simple Share Buttons Adder: Download failed. Failed to write request to temporary file.

Sometimes WordPress file and permission errors can be tricky but the solution for this was pretty simple.

Why it happens

During updates, WordPress places temporary files in a directory designated by the server’s configuration. This is not a directory specific to WordPress. It is available for all software to use as needed. Neither is this a plugin or theme issue. It is simply the result of needing more space in a directory than is available. It is common for hosts to limit the total file size of the tmp directory they make available for your sites to use.

Temporary files should normally be cleared out of tmp automatically after use but old files often get left behind, causing more space to be used than necessary. My hosting provider’s control panel shows me the path to my tmp directory and how much storage space it uses. 30 MB is apparently the limit for tmp in Media Temple’s shared hosting. Your host probably has a different limit.

What worked for me

To solve the problem of failing to write temporary files during a WordPress update, you will need to delete some files in your tmp directory.

You can do this by logging into your server via SFTP. Your host may also provide a file manager in their control panel. Be careful as there may be folders and files in your tmp directory that are currently in use (such as sessions) or that always need to remain there (such as for statistics). If you are unsure what is or is not safe to delete, play it safe and contact your host.

But, where is my tmp directory?

If you aren’t sure where your tmp directory is, SFTP into the server and poke around a bit. With Media Temple, my sites share a directory for temporary files at /data/tmp. Your host probably uses a different path. If you do not find it, check your control panel and search your host’s knowledge base. You may or may not have access to the tmp directory so if all else fails, contact your web host and ask them to clear it out.

Another solution

I have seen others recommend defining an alternate tmp directory path using the WP_TEMP_DIR constant in wp-config.php. This is not wrong but it seems like treating the symptom instead of solving the problem. Why complicate your setup if you do not have to?

Did it work for you?

Let me know in a comment if you encountered this problem and if this solution worked for you. If you have a better solution or additional advice, please share it.

 

9 Comments

  1. Hi Steven,

    I recently switched hosting from mt to GoDaddy over this very issue. I could never get it resolved and the switch has been good so far. I’m a little concerned about GoDaddy’s review on HostingReviews.io. I suppose we’ll see how they turn out.

    Thanks for posting this.

      • Actually that is one of the reasons why I decided to try Media Temple. Perhaps (mt)’s VPS does not have the problem. At the time I was using their grid service.

        Great advice and great post for those finding answers to the problem.

  2. Just looked in TMP file on Media Temple and their were just what I assume to be season files in there as they all start with sess_ then a random string of characters. They are all 0 bytes apart from one which was 17.18 kB so I assume my problems where noting to do with a full TMP folder.

    Jermaine’s comment does not fill me with confidence as I have about 10 sites on my MY account and am paid up until December 2015. Before I was getting the “Failed to write request to temporary file” updates where just failing and I was getting an error 502 in my admin. What was worse is that the .maintenance was getting left behind so each time an update failed I would have to manually remove it. Any ideas what it might be if my TMP folder is not full?

    I’ve contacted Media Temple about this before but they basically side it’s a problem with WordPress and not their problem. Really annoying response as I admin loads of WP sites across lots of different hosts and they are all fine.

    • I wonder if there’s some kind of limit on the number of files in tmp. I supposed you could try clearing out tmp even if the file size limit hasn’t been reached and see if it works.

      Otherwise, it could be a permissions issue on the directory itself.

      • After visiting the folder again I did notice that there were just 4 files in it instead of 10 I saw earlier. Sometimes plugin updates works sometimes they don’t. What definitely does not work is actual WordPress updates, they always fail. The permissions on the TMP folder are drwxrwxrwt don’t know how that translates to 3 digit number.

        • That should be normal for tmp.

          http://askubuntu.com/questions/432699/what-is-the-sticky-bit-t-permission-and-why-does-tmp-have-it

          It does seem like the problem could be something else then but I’m not sure what it is or why WordPress is having a problem with tmp.

          You may want to try the WordPress Support Forum: https://wordpress.org/support/

          I’m sorry Media Temple hasn’t been able to shed any light. Are you using Grid/Shared or their managed WordPress hosting?

        • Daniel Arturo Gutiérrez Colorado

          Hey lomokev, I’m having exactly the same issue while trying to update WP over MT :( I’ve chatted with 5 different support agents and after waiting for a diagnostic, they always tell me that the problem is wordpress itself :( Actually a wordpress famous plugin, duplicator, gives me the same 500 internal server error, and it seems it’s related to the time that php limits to do the scripting… I’m so dissapointed of MT! At the end, the support agents told me to try the community forum! c’mon!

  3. Thanks, this worked for me. All I did was to delete my trash to create some spaces then I deleted 2 folders from my /tmp directory.

Commenting has been turned off.