---
title: "Fixing Permission Denied errors"
url: https://phatdev.net/en/docs/sl-migrations/how-to-fix-file-permissions-issues
lang: en
updated: 2026-10-20
alternate:
  vi: https://phatdev.net/docs/sl-migrations/how-to-fix-file-permissions-issues
markdown: https://phatdev.net/en/docs/sl-migrations/how-to-fix-file-permissions-issues.md
---

# Fixing Permission Denied errors

Part of the doc set: [SL Migrations](https://phatdev.net/en/docs/sl-migrations.md)

> A build or restore fails with Permission Denied - how to handle it.

A common symptom:

```
fopen(/path/to/file): Failed to open stream: Permission denied
```

If the **ARCHIVE** build phase fails with this error, it means the web server user cannot read or write some file or folder.

## Understanding permissions

On Linux/Unix, every file has:
- **Owner**: the user that owns the file
- **Group**: the group that owns the file
- **Mode**: read/write/execute permissions for the owner, group and others (for example `644`, `755`)

The web server (Apache/Nginx + PHP) runs under a particular user, usually `www-data`, `apache`, `nobody` or `nginx`. This user must be able to read the plugin files and write to the backup folder.

## Fix 1: The backup folder is not writable

The `wp-content/backups-slm/` folder needs write permission.

**On shared hosting (cPanel)**: use File Manager → right-click the folder → Change Permissions → set `755`.

**On a VPS**:
```
chmod 755 wp-content/backups-slm/
chown -R [web-user]:[web-group] wp-content/backups-slm/
```

## Fix 2: Wrong owner on the plugin files

When you upload files through FTP/SFTP as a different user (not the web server user), the newly uploaded files have a different owner → the web server cannot read them.

**Fix**: change the owner of the whole plugin folder to the web server user. If you have no SSH access, contact your hosting provider or upload again with the hosting provider's own tool (cPanel File Manager usually creates files with the right owner).

## Fix 3: Mode too restrictive

A file mode of `600` or `640` can only be read by the owner. If the web server is not the owner → it fails.

**Fix**: set:
- Files: `644`
- Folders: `755`

Some folders need to be writable (such as `uploads/`, `backups-slm/`): `755` is enough with the right owner. Avoid `777` - it is less secure.

## Fix 4: SELinux / AppArmor

On systems with SELinux (CentOS/RHEL) or AppArmor (Ubuntu) in enforce mode, the web server can be denied even when the mode and owner are correct.

**Fix**: contact the server admin or check the SELinux log (`/var/log/audit/audit.log`) to see which rule is blocking.

## Fix 5: Plugin files edited locally

When you edit the plugin code through a local editor (VSCode, …), newly created files are owned by the editor's user → the web server may not be able to read them. When the ARCHIVE build phase packs the plugin into the archive, it fails on that file.

**Fix**: make sure every file in the plugin folder is owned by the web server user. Or set a group that lets the web server read, and `chmod` `664` (group write).

## See also

- [Create a new backup](https://phatdev.net/en/docs/sl-migrations/create-backup)
- [Server resources](https://phatdev.net/en/docs/sl-migrations/how-to-manage-server-resources-cpu-memory-disk)
