Cant start redis Can't chdir to '/data/redis': Permission denied

925 views
Skip to first unread message

David Montgomery

unread,
Mar 21, 2015, 11:57:26 PM3/21/15
to redi...@googlegroups.com
Hi,

I cant start redis

In the conf I have:
# Note that you must specify a directory here, not a file name.
dir /data/redis

# Can't chdir to '/data/redis': Permission denied

Here are the permisons:

drwxr-xr-x 2 root  root  4096 Mar 22 11:47 .


I also tired redis:redis and I am running as root

Greg Andrews

unread,
Mar 22, 2015, 3:16:43 AM3/22/15
to redi...@googlegroups.com
What are the outputs of these four commands?

df -h /data/redis
ls -ld /
ls -ld /data
ls -ld /data/redis

  -Greg

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

RAJESHWARAYYA MATHAPATI

unread,
Aug 15, 2021, 6:29:17 PMAug 15
to Redis DB
Hi,

Is that issue resolved, even i am facing same issue, when i try to change the default data directory to custom. below are the steps..


I have installed the redis in centos stream 8,

my requirement was to change default directory to custom directory default directory is "/var/lib/redis" i have changed it to "/root/data" and changed the directory owner/group to redis and permission to 755

changed the custom data directory path in "/etc/redis.conf" file and restarted the redis service..

it is getting failed and checked in the "/var/log/redis/redis.log" file the error is Can't chdir to '/root/data': Permission denied

Can anyone help me out on this issue..

Thanks is advance..

Greg Andrews

unread,
Aug 16, 2021, 1:41:03 PMAug 16
to Redis DB
The most likely issue is that the /root directory has permissions that are not allowing the Redis server process (running as the 'redis' user) to access the sub-directory you added, /root/data.

/root is very commonly the home directory for the root user, so it has very restrictive permissions. (and they should stay that way)  That's not a part of the filesystem that's recommended to store files/directories for daemons that run as other users.  My personal preference is to create /data for this purpose.  Since it's not a home directory for any user, it's also a suitable directory to mount another disk onto, and the resulting files/directories will consume space on the other disk rather than the root disk.  In this situation, I would create /data owned by root with permissions 755, (mount the other disk on /data, if that's your intent), and create a 'redis' subdirectory under /data, with the 'redis' subdirectory owned by the redis user and also permissions 755 (or perhaps 711).  Now the permissions on the redis subdirectory allow Redis to use it, and the permissions on the parent directory allow Redis to reach it.

This is my best guess about the cause of your error and my suggestion for a remedy.  I could be mistaken, though.

Kunal Gangakhedkar

unread,
Aug 18, 2021, 3:08:57 AMAug 18
to redi...@googlegroups.com
Given the centos base system, I would look into SELinux as well - it might be blocking access to the directories.
AFAIR, SELinux is by default enabled on centos/rhel systems in "enforcing" mode:
https://wiki.centos.org/HowTos/SELinux

As Greg mentioned, putting redis data under /root is not a good idea. Conventionally, /root is the home directory of the "root" user.

Kunal


Kunal Gangakhedkar

unread,
Aug 18, 2021, 3:32:58 AMAug 18
to redi...@googlegroups.com
I'm not suggesting to turn off SELinux - just be aware of its existence and find correct configuration to enable access to the required directories.

Kunal

Reply all
Reply to author
Forward
0 new messages