Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared Managed Cloud India
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Best lists Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Security · Guide

Correct File Permissions for WordPress

Short answer

Set WordPress files to 644, folders to 755, and wp-config.php to 600 or 640, with 400 or 440 as the strictest option where your host allows it. Check permissions in your host file manager or with ls -la over SSH, fix them with chmod or your file manager, and never use 777. Back up first, because wrong permissions can lock you out or break uploads and updates.

Key takeaways

  • Files use 644, folders use 755, and wp-config.php uses 600 or 640 on most hosts.
  • WordPress hardening guidance lists 400 or 440 as the strictest wp-config.php setting.
  • Never use 777, which lets every account on the server read and change a file.
  • Automatic WordPress updates set files to 644 and folders to 755.
  • Wrong permissions cause 403 errors, failed uploads, and updates that will not run.

What are WordPress file permissions?

File permissions are server rules that decide who can read, write, or run each file and folder on your site.

Every file and folder has three permission digits, one each for the owner, the group, and everyone else. The digits control read, write, and execute access. When permissions are too open, an attacker who reaches one account can change your files.

Ownership works with permissions. Files should be owned by your user account, and any file WordPress must write should be group-owned by the web server user, according to the hardening guide.

Permissions matter most on shared hosting, where many sites share one server. Sucuri notes that file permissions are the rules your server uses to decide who can read, write, and execute each file and folder in your installation (Mastering WordPress File Permissions).

What are the correct file permissions for WordPress?

Use 644 for files, 755 for folders, and 600 or 640 for wp-config.php on most hosts.

ItemPermissionWhy
All files644Owner can edit, others can only read
All folders755Owner can edit, others can enter and read
wp-config.php600 or 640Holds database passwords and secret keys
.htaccess644Web server reads it, others cannot change it
wp-content/uploads755WordPress must write uploads here

Jetpack gives the same baseline: 755 for most directories and 644 for most files, with wp-config.php at 600 or 640 (How to Set Correct WordPress File Permissions). Sucuri agrees, and adds that wp-config.php should be 600 where the host allows it.

Some hosts use different but equally safe settings, so check with your provider before overriding anything they configured. Managed hosts often set their own ownership model, and forcing 644 everywhere can break their update tools.

For wider context on how often WordPress sites face attacks, see WordPress security statistics.

What do the numbers 644 and 755 mean?

Each digit is the sum of read (4), write (2), and execute (1) for one group of users.

With 644, the owner can read and write (4 + 2 = 6), while the group and others can only read (4).

With 755, the owner can read, write, and enter the folder (4 + 2 + 1 = 7), while the group and others can read and enter it (4 + 1 = 5).

The execute bit means different things for files and folders. On a file it allows running the file as a program, which PHP files do not need.

On a folder it allows entering the folder, which is why folders need the 1 and files do not.

The first digit is the owner, the second is the group, and the third is everyone else. A 7 always includes write access, which is why folders need it and plain files usually do not.

How do you check your current file permissions?

Check permissions in your host file manager, over SFTP, or with the ls -la command over SSH.

In cPanel File Manager, open your WordPress folder, usually public_html, and look at the permissions column. Right-click any file or folder and choose \“Change Permissions\” to see its exact number.

Over SSH, run ls -la in your WordPress folder. The output shows a string such as -rw-r--r-- for 644 or drwxr-xr-x for 755, plus the owner and group names.

Check permissions right after a move or restore. Migrations and restores often reset ownership, and a site that worked on the old host can fail on the new one for this reason alone.

If you cannot see permissions in your file manager, switch to an FTP client such as FileZilla and right-click the file. The permissions dialog shows the numeric value and lets you change it.

How do you set file permissions with SSH?

Use SSH find commands to set every file and folder at once, after you back up the site.

find /path/to/your/wordpress/install/ -type d -exec chmod 755 {} \;
find /path/to/your/wordpress/install/ -type f -exec chmod 644 {} \;
chmod 600 wp-config.php

WordPress hardening guidance publishes these exact commands for directories and files (Hardening WordPress). Replace the path with your own install folder, and run them from the WordPress root.

Never run these commands on the wrong folder. A find command with a mistyped path can change permissions across the whole account, so confirm the path with pwd first.

How do you set file permissions in cPanel or FTP?

In cPanel File Manager or an FTP client, set folders to 755 and files to 644 one folder at a time.

  1. Open File Manager, go to your WordPress folder, and select the folders you want to change.
  2. Right-click, choose \“Change Permissions\”, enter 755, and tick the option to apply to directories only.
  3. Repeat the steps with 644, this time applying to files only.
  4. Set wp-config.php to 600 or 640 in the same dialog.

Some FTP clients show permissions as checkboxes instead of numbers. Tick read and write for the owner, read for the group, and read for others to get 644.

For 755, also tick execute for all three groups.

Jetpack advises the same approach: enter 755, apply to directories only, save, then repeat with 644 for files only (How to Set Correct WordPress File Permissions). Work one folder at a time so a mistake stays small.

How do you protect wp-config.php?

Protect wp-config.php first, because it holds your database password and the eight secret keys that sign login cookies.

WordPress hardening guidance says to store wp-config.php one directory level above the WordPress install where possible, so it sits outside the web root. It also says only you and the web server should be able to read the file, which generally means 400 or 440 permission (Hardening WordPress).

On Apache hosts, add a deny block to .htaccess to stop browsers reaching the file at all. The block targets wp-config.php and uses the two lines “order allow,deny” and “deny from all”.

The same hardening guide publishes this block for .htaccess. Place it at the very top of the file so it runs before other rules.

Replace the eight keys with fresh values from the official generator when you suspect a leak. WordPress provides a free generator at api.wordpress.org/secret-key/1.1/salt/ that returns eight fresh keys and salts, and new keys invalidate old login cookies.

Back up wp-config.php before you edit it. One wrong character in the file can take the whole site down, and a backup lets you restore it in seconds through File Manager or SFTP.

For more hardening steps, see our guide to add security headers to WordPress.

What goes wrong when permissions are too strict or too loose?

Permissions that are too strict break uploads and updates, while permissions that are too loose let attackers change your files.

Common symptoms and their causes:

  • A 403 Forbidden error on pages often means files or folders are too strict.
  • \“Upload failed\” or \“Unable to create directory\” means the uploads folder is not writable.
  • Updates that fail with \“could not create directory\” mean WordPress cannot write to wp-content.
  • Files changed by unknown users mean permissions are too loose, often 777.

WordPress sets files to 0644 and folders to 0755 during automatic updates, according to the hardening guide (Hardening WordPress). If your host uses a different owner for the web server user, updates may still fail, and your host can confirm the right owner.

If a scan finds changed files, reset permissions and look for the cause. Our guide to remove malware from WordPress explains the cleanup steps.

Audit permissions twice a year. Plugins and updates sometimes change file ownership, and a quick check in File Manager catches drift before it becomes a 403 error or a security hole.

After an update breaks the site, check permissions before you reinstall anything. Our guide to fix a site broken after a WordPress update covers the other common causes.

Avoid these mistakes:

  • Using 777 on any file or folder, which lets every account on the server change it.
  • Changing permissions without a backup to restore.
  • Setting wp-config.php to 644 on shared hosting.
  • Forgetting that plugin and theme updates need write access to wp-content.
  • Applying one recursive command to the wrong directory.

Frequently asked questions

What happens if I set everything to 777?

Every account on the server can read and change the file, including other sites on shared hosting. An attacker who reaches any account can then edit your code, add malware, or steal data. Use 644 for files, 755 for folders, and 600 or tighter for wp-config.php instead.

Why does WordPress say it cannot write a file after I change permissions?

WordPress needs write access to wp-content/uploads for media, and to the themes and plugins folders for updates. Check that the uploads folder is 755 and owned by the right user. If the owner is wrong, ask your host to fix ownership rather than opening permissions to 777.

Can I set wp-config.php to 400?

Yes, if the PHP process can still read the file. On many hosts 400 works when PHP runs as the file owner, and 440 works when PHP reads through the group. If the site shows an error after the change, step back to 640 or 600 and ask your host which value fits their setup.

Do permissions matter on managed WordPress hosting?

Yes, and on managed hosting you should usually leave permissions alone. Managed hosts set their own ownership and permission model, and changing it can break their update and backup tools. Ask your host for their recommended values before you change anything.

How do I reset permissions if I locked myself out?

Use your host file manager or SSH as the account owner to set the files back to 644 and folders to 755. If you cannot reach the files at all, ask your host support to reset ownership and permissions for the account. Keep a backup before you change permissions again.

Sources

  1. How to Set Correct WordPress File Permissions (and Fix Errors) Jetpack
  2. Mastering WordPress File Permissions: A Guide for All Levels Sucuri
  3. Hardening WordPress WordPress Developer Resources
  4. WordPress Secret Key Generator WordPress.org

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

WPLegible editors

Researched from the primary sources listed above and checked against our editorial rules. About the site · How we test