Question

Apache won't restart. mktemp failed

My google skills are failing me here. There’s definitely space on my server, about 51% actually. I’m getting this error when I try to restart apache:

mktemp: failed to create file via template ‘/tmp/tmp.XXXXXXXXXX’: No space left on device /etc/init.d/apache2: 91: /etc/init.d/apache2: cannot create : Directory nonexistent *

  • The apache2 configtest failed.
Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

You might want to check /proc/mounts to see if your filesystem is mounted as read-only (“ro”) rather than read-write (“rw”). That can happen, for example, if there’s filesystem corruption.

Also, if you’ve mounted a separate partition as /tmp, you’d want to specifically make sure that partition is not full.

I have resolved the issue. Find the largest directory and clear if its safe.

Steps :

First I found the large size folder with ssh : du -h --max-depth=1 recursively started from root and kept on repeating till I found the exact folder. Once I found that folder in my case it was var/session folder it was more than 7GB , I deleted the folder (It was safe to delete as I was ok with loosing the session data ) and restarted the server. Ssh- root-yourserver/var/www/html/var#: rm -rf session recreated the directory session once again. You can delete the files inside but for me it was taking too long to delete individual files so I deleted the folder which was fast . It worked. The session folder was very big because of lot of session files. In your case it may anything which is suspiciously very big, may be log file folder or 3rd party extension folder, find that folder and if its safe to delete it, clear that folder and restart the server. ssh: service apache2 restart

You’ll need to free up your inode usage Run:

$ sudo df -i 

to see your inode usage then you can run

$ for i in /*; do echo $i; find $i |wc -l; done

run this for each directory with very large number of files.

For example if you get:

/var
1002793

You can then run:

$ for i in /*; do echo $i; find $i |wc -l; done

Once you get to the directory containing the huge number of small files you can delete all those files if they are not so important or move them to another system or device. Simple type:

$ rm -rf /directory_containing_annoying_small_files/

That’s it. Check again by running

$ df -i