How to Fix File and Folder Permissions Error in WordPress

Understanding File and Folder Permissions in WordPress
WordPress, built on PHP, requires specific file and folder permissions to function correctly. These permissions dictate who can read, write, and execute files on your server. Incorrect permissions can lead to various errors, including:
- Failed plugin installations
- Theme updates not working
- Media uploads failing
- White screen of death
- Internal Server Errors
Permissions are represented by a three-digit number, such as 755 or 644. Each digit corresponds to a user class:
- **Owner (User):** The user who owns the file or folder (typically the server user running PHP).
- **Group:** The group the owner belongs to.
- **Public (World):** Everyone else on the server.
Each digit is a sum of the following values:
- **4:** Read permission (allows viewing the file or listing the folder’s contents).
- **2:** Write permission (allows modifying the file or adding/deleting files within the folder).
- **1:** Execute permission (allows running the file as a program or entering the folder).
Therefore:
- **7:** Read + Write + Execute (4 + 2 + 1)
- **6:** Read + Write (4 + 2)
- **5:** Read + Execute (4 + 1)
- **4:** Read only
Common WordPress permissions are:
- **Files:** 644 (Owner: Read/Write, Group: Read, Public: Read)
- **Folders:** 755 (Owner: Read/Write/Execute, Group: Read/Execute, Public: Read/Execute)
- **wp-config.php:** 640 or 440 (highly sensitive file, restrict access)
Identifying Permission Errors
Before attempting to fix permissions, it’s crucial to identify that they are indeed the root cause of your WordPress issues. Look for error messages that mention:
- “Permission denied”
- “Unable to write to file”
- “Failed to open stream: Permission denied”
- “Is not writable by server”
You can also check your WordPress Site Health report (Tools > Site Health) for potential permission-related warnings. Plugin installation failures or media upload problems often point to permission issues. If you’ve recently moved your WordPress site to a new server or made changes to your server configuration, permissions are a prime suspect.
Methods to Fix File and Folder Permissions
There are several ways to correct file and folder permissions in WordPress. Choose the method that best suits your technical comfort level and access to server resources.
Using an FTP Client
FTP (File Transfer Protocol) clients like FileZilla, Cyberduck, or Transmit provide a user-friendly way to modify file permissions.
**Steps:**
1. **Connect to your server:** Enter your server’s hostname, username, and password in your FTP client and connect.
2. **Navigate to your WordPress directory:** Locate the directory where your WordPress installation is located (usually `public_html`, `www`, or the domain name itself).
3. **Select folders:** Select the folders you want to modify (e.g., `wp-content`, `wp-includes`, `wp-admin`). Right-click on the selected folders and choose “File Permissions” or a similar option.
4. **Enter the desired permission:** Enter `755` in the “Numeric value” field.
5. **Apply to subdirectories:** Check the box that says “Recurse into subdirectories” and select “Apply to directories only.” This ensures the change applies to all folders within the selected directory.
6. **Click “OK”:** The FTP client will now change the permissions for all selected folders and their subfolders.
7. **Select files:** Repeat the process for files. Select all the files in your WordPress directory, right-click, and choose “File Permissions.”
8. **Enter the desired permission:** Enter `644` in the “Numeric value” field.
9. **Apply to subdirectories:** Ensure “Recurse into subdirectories” is checked, and select “Apply to files only.”
10. **Click “OK”:** The FTP client will now change the permissions for all selected files and their subfiles (if any).
11. **Special Case: wp-config.php:** Locate `wp-config.php` and set its permissions to `640` or `440`. This file contains sensitive information and should have restricted access.
12. **Test your site:** After changing permissions, clear your browser cache and test your WordPress site to see if the errors are resolved.
Using a cPanel File Manager
cPanel’s File Manager provides a web-based interface for managing files and folders on your server.
**Steps:**
1. **Log in to cPanel:** Access your cPanel account through your web hosting provider’s website.
2. **Open File Manager:** Find the “File Manager” icon and click on it.
3. **Navigate to your WordPress directory:** Locate the directory where your WordPress installation is located (usually `public_html`, `www`, or the domain name itself).
4. **Select folders:** Select the folders you want to modify (e.g., `wp-content`, `wp-includes`, `wp-admin`).
5. **Change permissions:** Right-click on the selected folders and choose “Change Permissions.”
6. **Enter the desired permission:** Check the appropriate boxes to set the permissions to `755`. This usually corresponds to:
- Owner: Read, Write, Execute
- Group: Read, Execute
- Public: Read, Execute
7. **Apply recursively:** Check the box that says “Apply changes to all subdirectories.”
8. **Click “Change Permissions”:** The File Manager will now change the permissions for all selected folders and their subfolders.
9. **Select files:** Repeat the process for files. Select all the files in your WordPress directory, right-click, and choose “Change Permissions.”
10. **Enter the desired permission:** Check the appropriate boxes to set the permissions to `644`. This usually corresponds to:
- Owner: Read, Write
- Group: Read
- Public: Read
11. **Apply recursively:** Ensure “Apply changes to all subdirectories” is checked.
12. **Click “Change Permissions”:** The File Manager will now change the permissions for all selected files and their subfiles (if any).
13. **Special Case: wp-config.php:** Locate `wp-config.php` and set its permissions to `640` or `440`. This file contains sensitive information and should have restricted access.
14. **Test your site:** After changing permissions, clear your browser cache and test your WordPress site to see if the errors are resolved.
Using SSH (Command Line)
SSH (Secure Shell) provides a command-line interface for interacting with your server. This method is more technical but offers greater control.
**Steps:**
1. **Connect to your server via SSH:** Use an SSH client like PuTTY (Windows) or the Terminal (macOS/Linux) to connect to your server using your username and password.
2. **Navigate to your WordPress directory:** Use the `cd` command to navigate to the directory where your WordPress installation is located. For example: `cd /var/www/html/yourdomain.com`
3. **Change folder permissions:** Use the `find` command with `chmod` to change the permissions of all folders to `755`.
`find . -type d -exec chmod 755 {} ;`
This command does the following:
- `find . -type d`: Finds all directories ( `-type d`) starting from the current directory (`.`).
- `-exec chmod 755 {} ;`: Executes the `chmod 755` command on each directory found. `chmod 755` changes the permissions to 755. `{}` represents the name of the directory found by the `find` command. `;` marks the end of the command.
4. **Change file permissions:** Use the `find` command with `chmod` to change the permissions of all files to `644`.
`find . -type f -exec chmod 644 {} ;`
This command does the following:
- `find . -type f`: Finds all files ( `-type f`) starting from the current directory (`.`).
- `-exec chmod 644 {} ;`: Executes the `chmod 644` command on each file found. `chmod 644` changes the permissions to 644. `{}` represents the name of the file found by the `find` command. `;` marks the end of the command.
5. **Special Case: wp-config.php:** Change the permissions of `wp-config.php` to `640` or `440`.
`chmod 640 wp-config.php` or `chmod 440 wp-config.php`
6. **Correct ownership (if necessary):** Sometimes, incorrect file ownership can cause permission errors. You’ll need to identify the correct user and group that your web server uses. This is typically `www-data` or `apache`. Use the `chown` command to change ownership.
`chown -R www-data:www-data .` (replace `www-data` with the appropriate user/group)
This command changes the owner and group of all files and directories within the current directory to `www-data`. The `-R` option makes the change recursive, affecting all subdirectories and files. **Important:** Use the correct user/group, otherwise your site *will* break. Consult your hosting provider if you are unsure.
7. **Test your site:** After changing permissions, clear your browser cache and test your WordPress site to see if the errors are resolved.
Using a WordPress Plugin
While not recommended as a primary solution (as it can potentially introduce security risks if the plugin is poorly coded), some WordPress plugins can help with permission issues. These plugins usually provide a simplified interface for resetting permissions to the recommended values. Search the WordPress plugin repository for terms like “file permissions” or “fix permissions.” Be sure to thoroughly research any plugin before installing it, checking its reviews, ratings, and developer reputation. **Always delete the plugin after you are finished using it.**
Troubleshooting Permission Issues
If you’ve followed the steps above and are still experiencing permission errors, consider these troubleshooting tips:
- **Server Configuration:** Some servers have specific security configurations that may override standard permissions. Contact your hosting provider for assistance.
- **Incorrect User/Group Ownership:** As mentioned in the SSH section, incorrect file ownership can be a major problem. Use the `chown` command (via SSH) to correct it. Get the proper user/group from your hosting provider.
- **.htaccess File:** A corrupted or misconfigured `.htaccess` file can sometimes cause permission-related errors. Try temporarily renaming it to `.htaccess_old` to see if that resolves the issue.
- **Plugin/Theme Conflicts:** In rare cases, a plugin or theme might be interfering with file permissions. Try deactivating all plugins and switching to a default WordPress theme to see if that resolves the problem. Reactivate them one by one to identify the culprit.
- **ModSecurity:** ModSecurity is a web application firewall that can sometimes block legitimate requests, leading to permission-like errors. Check your server’s ModSecurity logs for any blocked requests related to your WordPress site. You may need to contact your hosting provider to adjust ModSecurity rules.
- **Disk Space:** Ensure your server has enough free disk space. A full disk can sometimes mimic permission errors.
- **Database Permissions:** Though less common, problems with database user permissions *can* manifest as write errors in WordPress. Confirm your database user has the correct privileges (SELECT, INSERT, UPDATE, DELETE, CREATE, DROP) for your WordPress database.
Preventing Future Permission Issues
To minimize the risk of future permission problems:
- **Choose a reputable hosting provider:** A good hosting provider will properly configure server permissions for WordPress.
- **Avoid manually editing core WordPress files:** If you need to make changes to core files, use child themes or plugins instead.
- **Keep WordPress, themes, and plugins updated:** Updates often include security patches that address potential permission vulnerabilities.
- **Be cautious when installing plugins:** Only install plugins from trusted sources.
- **Back up your WordPress site regularly:** Backups allow you to quickly restore your site if something goes wrong.
- **Understand the implications of server-side changes:** Be careful when making changes to your server configuration, as incorrect settings can lead to permission problems.
- 11 Best WordPress Login Page Plugins (Secure & Customizable)
- How to Easily Add reCAPTCHA to WordPress Comment Form
- How to Fix the “Sorry, You Are Not Allowed to Access This Page” Error in WordPress
- How to Fix WordPress ‘jQuery is not defined’ Error (6 Ways)
- How to Fix WordPress Updating Failed / Publishing Failed Error
- How to Fix the Invalid JSON Error in WordPress (Beginner’s Guide)
- How to Fix WordPress Login Page Refreshing and Redirecting Issue