GICT knowledge base
Apache Error: Too Many Open Files – Could Not Open Transfer – Unable To Open Logs
Published
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.
Related guides
How to Restrict an SSH Key to One Command
Restrict an SSH key to one command with authorized_keys options. Protect the command and check that unwanted shell and forwarding access are denied.
Linux and CommandsSelf-Hosted Video Processing With FFmpeg: A Practical Guide
Learn how to self-host video processing on a VPS using FFmpeg, with practical commands for conversion, compression, thumbnails, and automated workflows.
Linux and CommandsHow to use nohup: Commands in Linux That Survive Terminal Closes
Keep commands running after you close the terminal. nohup examples with wget, Python, rsync, and Docker on any VPS.
Linux and CommandsHow to Fix “Too Many Open Files” Error on Linux Servers
Learn how to fix the "Too Many Open Files" error on Linux servers by understanding file descriptors, adjusting limits, and diagnosing leaks effectively.
