Apache won't restart. mktemp failed

August 24, 2015 10.9k views
Apache

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.
1 comment
  • I have resolved the issue. Find the largest directory and clear if its safe.

    Steps :

    1. 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.
    2. 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 taking too long to delete individual files so I deleted the folder which was fast .

    3. 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

7 Answers

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.

  • That was the clue I needed! Ran mount -o remount,rw / and everything is back up. Thanks so much!

    EDIT: Actually that wasn't it. i'll keep looking, but it's a clue!

Great! You're very welcome.

i have problem with apache2 not runing when i start apace2 that error show

mktemp: failed to create file via template ‘/tmp/tmp.XXXXXXXXXX’: No such file or directory
/etc/init.d/apache2: 91: /etc/init.d/apache2: cannot create : Directory nonexistent

Please help me how can i fix this problem my all websites gose down ... please help

Hey
I am having the exact same issue, none of the services, apache2, mysql, ssh is running
Does anyone have any solution for this
Thanks

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

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

Have another answer? Share your knowledge.