Fix file and folder permissions
Every file and folder has a permission setting that says who can read, change, or run it. Wrong permissions cause 403 and 500 errors, failed uploads, and security holes.
The right settings
| Item | Permission | Why |
|---|---|---|
| Folders | 755 |
You can change them. Others can only look inside |
| Files (HTML, images, PHP, CSS) | 644 |
You can change them. Others can only read |
wp-config.php |
600 or 640 |
Only you can read it. It holds your database password. Your site's PHP runs as your own user, so it can still read the file |
.htaccess |
644 |
The server needs to read it |
wp-content/uploads |
755 for folders, 644 for files |
Normal |
Anything set to 777 |
Never | Anyone can change it. Attackers use this |
What the numbers mean
Each digit is for one group: owner, group, others. Each digit adds up read (4), write (2), and run (1).
| Number | Meaning |
|---|---|
7 = 4+2+1 |
Read, write, run |
6 = 4+2 |
Read, write |
5 = 4+1 |
Read, run |
4 |
Read only |
0 |
Nothing |
So 644 means the owner can read and write, and the group and others can only read. 755 means the owner can do everything, and others can read and enter. 600 means only the owner can read and write.
Symptom, cause, fix
| Symptom | Likely cause | Fix |
|---|---|---|
| 403 on one file or folder | Too strict, such as 600 on an image, or 700 on a folder |
Set files to 644 and folders to 755 |
| 500 error on a script | Set to 777, or a folder is 777 |
Set files to 644 and folders to 755 |
| Can't upload in WordPress, "Unable to create directory" | Upload folder isn't writable by you | Folders to 755, check ownership |
| Plugin or theme update fails | Same | Same |
| After a restore or migration, everything is 403 | Permissions or owner came back wrong | Reset with the commands below |
Change one item in the file manager
- Open Account → Hosting → your site → Files → File manager.
- Select the file or folder and open Permissions.
- Tick the boxes to match, or type the number.
- Save.
See Browse and edit your files.
Fix everything at once with SSH
Connect with SSH. Add your key under Account → Hosting → your site → Developer → SSH access. See Connect with SSH. Make a backup first. See Download a backup copy.
cd ~/public_html
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chmod 600 wp-config.php
The first command sets every folder to 755. The second sets every file to 644. The third sets wp-config.php to 600.
For a WordPress site in a subfolder, change into that folder first. For an addon domain, run it in that domain's folder.
Check a result.
ls -l wp-config.php
-rw------- 1 nsbakery nsbakery 3012 Nov 30 09:12 wp-config.php
-rw------- is 600. The first dash means a file. Then come the owner, group, and others, three characters each.
Ownership
Files must belong to your hosting account. If a file is owned by another user, the permission change won't help. This can happen after a migration. Contact us. See What to include when you ask for help.
Important: Don't change the permissions of your home folder (/home/yourusername) or system folders. Work only inside public_html and other site folders.
If something goes wrong
| Problem | Fix |
|---|---|
| Site broke after setting wp-config.php to 600 | Try 640, and tell us |
| Scripts that need to write files fail | The script's folder needs 755 and your user must own it. Don't use 777 |
chmod says "Operation not permitted" |
The file belongs to another user. Ask us |
| Many files changed that shouldn't have | Restore from backup. See Restore files from a backup |
Security note
Unusual permissions can also be a sign of a hacked site. If files you haven't touched are 777 or writable by others, see Recover a hacked website.
Still stuck? Ask us and we'll walk you through it.