The “Failed to set rlimit for open files” error can occur when starting the memcached service, indicating that the service is not able to set the maximum number of open files allowed for the system. This can happen for several reasons:
- The system’s ulimit for open files is set too low: You can check the current open file limit by running the command
ulimit -n
. - The user running the memcached service does not have permission to set the open file limit: Memcached requires that the user running the service has permission to set the open file limit.
- The system’s open file limit is too low: The default limit for open file descriptors on some systems is quite low. You can check the limit by running the command
ulimit -n
and you can increase the limit by editing the/etc/security/limits.conf
file and adding the entry* - nofile unlimited
and then rebooting the system. - The memcached configuration file is not set with the correct value for the open file limit: You can check the value of the open file limit in the memcached configuration file, usually located at
/etc/memcached.conf
or/usr/local/etc/memcached.conf
. - The memcached service is running as a non-root user, in this case the user running memcached does not have permission to raise the open file limit.
You can fix this error by increasing the open file limit on the system, and making sure that the user running the memcached service has permission to set the open file limit. You can also check the memcached configuration file to ensure that it has the correct value for the open file limit.
Also, if the service is running as a non-root user, you can try running the service as a root user or giving the user permission to raise the open file limit.
It is also recommended to check the memcached logs for more information about the error.