Apache Error: Too Many Open Files – Could Not Open Transfer – Unable To Open Logs

Posted on January 28th, 2017

This error occurs when Apache fails to start. You can find this error located in the error logs on the server. The default Apache error log location is /usr/local/apache/logs/error_log. The error explains that Apache failed to start due to the low number of file descriptors. You may need to increase the maximum number of file descriptors to make Apache run again. You also may need to ask your hosting provider to increase the value and fix this if you are using a shared server where you don’t have root access. This action can only be performed as root user.

When Apache doesn’t start and the error log displays, “too many open files: could not open transfer unable to open logs” then you may need to perform the following the steps to fix this.

 

1) Connect to your server via SSH as root user.

 

2) Open the Apache startup script using your favorite text editor. The startup script locations are:

/etc/init.d/httpd

or

/usr/sbin/apachectl

I am using vi which is my favorite text editor to edit apache startup script.

$ vi /etc/init.d/httpd

 

3) Add the below line to the Apache startup script and save it.

ulimit -n 65536

Ulimit provides control over the resources available to the shell (user) and to processes started by it. The -n switch is used to set maximum number of open file descriptors.

 

4) Check the current limit of file descriptors in the file /proc/sys/fs/file-max. The file-max is the maximum File Descriptors (FD) enforced on a kernel level, which cannot be surpassed by all processes without increasing. We generally tune this file to improve the number of open files by increasing the value of /proc/sys/fs/file-max. You can use cat command to read the file-max value.

$ cat /proc/sys/fs/file-max

1024

 

5) If the fs.file-max is quite small (several thousand or so), it should be changed to a higher value.

Echo “65535” > /proc/sys/fs/file-max

 

6) If you want to save this new value to survive future reboots, you may add it to /etc/sysctl.conf file. The sysctl.conf is a simple file containing sysctl values to be read in and set by sysctl.

#Maximum number of open files permitted

fs.file-max = 65535

 

7) To load the new values from the sysctl.conf file run:

$ sysctl -p /etc/sysctl.conf

The sysctl command is used to view, set, and automate kernel settings in the /proc/sys/ directory. The -p switch is to load in sysctl settings from the file specified or /etc/sysctl.conf

 

8) Now restart the Apache service by running either of the below given commands:

$ /etc/init.d/httpd restart

or

$ service httpd restart

 

9) To check the current status, run either of the following commands:

$ /etc/init.d/httpd status

or

$ service httpd status

 

After completing these steps you can see Apache is active and running.

 

If you need any further assistance please contact our support department.

 

 

Leave a Reply