Payments are experiencing issues due to temporary restrictions in Russia. If your payment does not go through, please submit a support request.Our support team is available 24/7 — we are always here to help with hosting and server issues.We are now accepting requests for dedicated server rental and colocation services in our data center.Reminder: we recommend enabling backups for additional data protection.A new VPS/VDS lineup with NVMe storage and improved performance is now available.Maintenance work on some servers has been completed. All services are operating normally.
Article3 min readViews0

Permission Denied: How to Find the Problem in the Path and Access Rights

Use namei and stat to check the entire file path, owner, and access mode before changing the site directory permissions.

Access check via card at the server room door
In this article

The file exists, but the application receives a permission denied error. A common mistake is to immediately grant access to everyone. This can hide the root cause and expose data to unauthorized users. First, determine which user is accessing the file and where in the path access is blocked.

Check every directory in the path

The examples apply to Linux with util-linux and GNU Coreutils. The path /var/www/site/config.php is conditional: replace it with the actual problematic file without outputting its contents.

namei -l /var/www/site/config.php

The command displays path components, their types, owners, and permissions. To access the file, appropriate permissions are required on parent directories. Therefore, correct permissions on the file itself do not help if one of the higher-level directories is inaccessible to the process user.

Pay attention to symbolic links. The actual target may be located elsewhere with different rules. You must check the path that the application actually uses, not a similar file in a project copy.

Read the object metadata

For a single file:

stat /var/www/site/config.php

By default, GNU stat describes the symbolic link itself if the specified entry is a link. To follow to its target, use -L. Do not mix these two results when comparing owner and mode.

Check the owner, group, and permissions, then map them to the workflow user. The terminal user may have access that PHP or the background job lacks. Successful reading in a personal session does not confirm application access.

Standard permissions may be insufficient

If the mode looks appropriate, check the ACLs and security policies applied in your system. Access may also be restricted by the container, mount namespace, or service settings. Do not disable such mechanisms for testing without understanding the specific failure.

Example: after migrating a project, the file is owned by a user who does not exist in the new server's working scheme. The fix must restore the expected ownership model. Mass-assigning identical permissions to all files ignores the distinction between directories, public resources, and configuration with secrets.

Clarify the operation type

Reading an existing file, creating a new file, and replacing via a temporary file require different permissions. An application may successfully read configuration but lack the right to create a temporary record in the directory. Therefore, the report must specify not only the path but also the operation being performed.

Do not include passwords or key contents in diagnostic output. For the first stage, the process name, anonymized path, owner, group, and mode are usually sufficient. If the issue involves a configuration with secrets, reading the file contents is not required.

Check the patch

After the agreed change, repeat the original operation on behalf of the application and re-examine the metadata. Ensure the intended scenario works and access has not been expanded to unnecessary users. A good fix explains why a specific process received the necessary permission. It is not merely the disappearance of an error after recursively opening the entire directory.

Discussion 0

Share your experience and ask questions. Comments without links appear after editorial review.

No comments yet. Start the discussion.