{"id":8533,"date":"2026-11-28T06:32:32","date_gmt":"2026-11-28T05:32:32","guid":{"rendered":"https:\/\/harmonweb.com\/blog\/?p=8533"},"modified":"2026-11-28T06:32:32","modified_gmt":"2026-11-28T05:32:32","slug":"secure-wordpress-file-permissions","status":"publish","type":"post","link":"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/","title":{"rendered":"How to Secure WordPress File Permissions and Protect Your wp-config.php File"},"content":{"rendered":"<p>File permissions in WordPress are an important factor in safeguarding the website against attacks. When the settings of the files and folders are too loose, the hackers can get an opportunity to change the website content and even <a href=\"https:\/\/harmonweb.com\/blog\/how-to-remove-malware-from-a-wordpress-website-without-losing-your-content\/\" target=\"_blank\" rel=\"noopener\">inject some malware<\/a>.<\/p>\n<p>The file that needs special care is <strong><span style=\"font-size: 10pt\">wp-config.php<\/span><\/strong>. It includes some configuration settings that include the credentials with which WordPress communicates with its database. If an intruder gets hold of this file, he may have some more than just affecting the site&#8217;s appearance.<\/p>\n<p>Protecting your WordPress site includes giving the proper file permissions and protecting your sensitive configuration files from any access. This tutorial will help you do that without interfering with your website\u2019s functionality.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_91 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6b0f4a3a470dd\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6b0f4a3a470dd\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#WordPress_File_Permissions_and_Their_Significance\" >WordPress File Permissions and Their Significance<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#Understanding_Read_Write_and_Execute_Permissions\" >Understanding Read, Write and Execute Permissions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#How_Incorrect_File_Permissions_Make_WordPress_Sites_Vulnerable\" >How Incorrect File Permissions Make WordPress Sites Vulnerable<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#WordPress_File_Permissions_%E2%80%93_What_are_the_Recommendations\" >WordPress File Permissions &#8211; What are the Recommendations?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#Permissions_for_Files_on_WordPress\" >Permissions for Files on WordPress<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#Recommended_Permissions_for_WordPress_Folders\" >Recommended Permissions for WordPress Folders<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#Reasons_Why_You_Should_Not_Use_Permission_777\" >Reasons Why You Should Not Use Permission 777<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#Why_Is_wp-configphp_File_So_Important_to_Protect\" >Why Is wp-config.php File So Important to Protect?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#Sensitive_Data_Within_wp-configphp\" >Sensitive Data Within wp-config.php<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#What_Will_an_Attacker_Do_Once_He_Gains_Access_to_wp-configphp\" >What Will an Attacker Do Once He Gains Access to wp-config.php?<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#How_to_Secure_Your_WordPress_File_Permissions\" >How to Secure Your WordPress File Permissions<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#1_Setting_File_Permissions_Using_cPanel_or_FTP_Client\" >1. Setting File Permissions Using cPanel or FTP Client<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#2_Changing_File_Permissions_via_SSH\" >2. Changing File Permissions via SSH<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#How_to_Protect_Your_WordPress_wp-configphp_File\" >How to Protect Your WordPress wp-config.php File<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#1_Limiting_Access_to_wp-configphp\" >1. Limiting Access to wp-config.php<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#2_Move_wp-configphp_Outside_the_Public_Web_Root\" >2. Move wp-config.php Outside the Public Web Root<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#3_Prevent_Direct_Access_to_wp-configphp_from_Web_Browsers\" >3. Prevent Direct Access to wp-config.php from Web Browsers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#4_Disable_File_Editing_from_the_WordPress_Dashboard\" >4. Disable File Editing from the WordPress Dashboard<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#Common_File_Permission_Mistakes_to_Avoid\" >Common File Permission Mistakes to Avoid<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#How_to_Find_out_Whether_Your_WordPress_File_Permissions_Are_Secure\" >How to Find out Whether Your WordPress File Permissions Are Secure<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#Conclusion\" >Conclusion<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#Are_You_Looking_for_Reliable_WordPress_Hosting\" >Are You Looking for Reliable WordPress Hosting?<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"WordPress_File_Permissions_and_Their_Significance\"><\/span>WordPress File Permissions and Their Significance<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>File permissions in WordPress regulate who is allowed to perform operations such as reading, writing, modifying or executing a particular file, as well as who has permission to access certain directories on your host server.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Understanding_Read_Write_and_Execute_Permissions\"><\/span>Understanding Read, Write and Execute Permissions<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The file permissions in Linux include three main categories:<\/p>\n<ul style=\"list-style-type: square\">\n<li>Read (4): Gives permission to a user to read a file or list its contents in case of a directory.<\/li>\n<li>Write (2): Gives permission to a user to modify a file or create\/deletes files from a directory.<\/li>\n<li>Execute (1): Gives permission to a user to execute a file or access a directory.<\/li>\n<\/ul>\n<p>These permissions are identified by three digits, one for each category of the owner, group, and others.<\/p>\n<p>For instance, <a href=\"https:\/\/harmonweb.com\/blog\/how-to-secure-your-wordpress-site-without-plugins\/\" target=\"_blank\" rel=\"noopener\">permission 755<\/a> means that the owner has read, write, and execute permissions while group and others have read and execute permissions. Permission 644 will give the owner read and write permission while giving read permission to everyone else.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_Incorrect_File_Permissions_Make_WordPress_Sites_Vulnerable\"><\/span>How Incorrect File Permissions Make WordPress Sites Vulnerable<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Incorrect file permissions can make a WordPress site vulnerable to different security threats. This is because any unauthorized user will be able to alter vital files, making it easy for them to inject malicious code.<\/p>\n<p>Too many permissions will also make it easy for scripts or applications that have been compromised to alter files that they are not supposed to have access to.\u00a0On the other hand, permissions that are too restrictive may prevent WordPress from uploading media, installing u<a href=\"https:\/\/harmonweb.com\/blog\/why-wordpress-auto-updates-fail-and-how-to-resolve-them\/\" target=\"_blank\" rel=\"noopener\">installing updates<\/a> or performing other essential operations.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"WordPress_File_Permissions_%E2%80%93_What_are_the_Recommendations\"><\/span>WordPress File Permissions &#8211; What are the Recommendations?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>There isn\u2019t any specific set of permissions that apply to all WordPress sites out there. The right configuration may vary depending on file ownership and the web server PHP handling environment.<\/p>\n<p>Here are some common configurations:<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Permissions_for_Files_on_WordPress\"><\/span>Permissions for Files on WordPress<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><a href=\"https:\/\/harmonweb.com\/blog\/how-to-assign-permissions-to-files-and-folders-in-cpanel\/\" target=\"_blank\" rel=\"noopener\">Regular files in WordPress usually have permissions of 644<\/a>. This gives permission to the owner to read and write files, whereas other users are able to read them only.<\/p>\n<p>A more stringent file setting may be required for important files. For instance, <span style=\"font-size: 10pt\"><strong>wp-config.php<\/strong><\/span> could have settings of 400 or 440 depending on the web server.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Recommended_Permissions_for_WordPress_Folders\"><\/span>Recommended Permissions for WordPress Folders<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Folks often assign 755 permissions to WordPress folders. The folder owner has the ability to read, write and execute the folder, and all others have the ability to read and execute without making any changes to the folder.<\/p>\n<p>In certain cases, you can assign 750 permissions in your hosting environment.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Reasons_Why_You_Should_Not_Use_Permission_777\"><\/span>Reasons Why You Should Not Use Permission 777<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Permission 777 gives all individuals the rights to read, write, and execute files\/directories. The reason why it creates security vulnerabilities is that other users or processes could potentially modify the files.<\/p>\n<p>Do not use permission 777 as a means of solving <a href=\"https:\/\/harmonweb.com\/blog\/how-to-fix-wordpress-plugin-installation-failed-errors\/\" target=\"_blank\" rel=\"noopener\">permission problems<\/a> related to WordPress. One should determine the problem regarding ownership or access and fix it by solving the issue of the respective file or directory. If you are not sure about it, get in touch with your web host before any modifications.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Why_Is_wp-configphp_File_So_Important_to_Protect\"><\/span>Why Is wp-config.php File So Important to Protect?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-size: 10pt\"><strong>wp-config.php<\/strong><\/span> file is among the most sensitive files within a WordPress site. The file connects WordPress with its database and keeps the critical configuration details which are necessary for running the website.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Sensitive_Data_Within_wp-configphp\"><\/span>Sensitive Data Within wp-config.php<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The file can contain:<\/p>\n<ul style=\"list-style-type: square\">\n<li>Prefix of WordPress database tables.<\/li>\n<li>Authenticating keys and security salts.<\/li>\n<li>Database name, username, and password.<\/li>\n<li>Database host information.<\/li>\n<li>Various additional website configurations.<\/li>\n<\/ul>\n<p>If the wrong hands get hold of these, it is possible that they will use them to gain access to your database or website.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_Will_an_Attacker_Do_Once_He_Gains_Access_to_wp-configphp\"><\/span>What Will an Attacker Do Once He Gains Access to wp-config.php?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The hacker that will have gained the database credentials will try to establish a connection to the database so as to access the website data. The attacker can also alter data, <a href=\"https:\/\/harmonweb.com\/blog\/how-to-remove-malware-from-a-wordpress-website-without-losing-your-content\/\" target=\"_blank\" rel=\"noopener\">make illegal administrator accounts<\/a>, or affect how websites work based on the permissions given to the database user.<\/p>\n<p><a href=\"https:\/\/harmonweb.com\/blog\/critical-wordpress-security-vulnerability-update-your-website-immediately\/\" target=\"_blank\" rel=\"noopener\">Authentication keys and security salts<\/a> might compromise the already existing security measures as well. That is why limiting access to <span style=\"font-size: 10pt\"><strong>wp-config.php<\/strong><\/span> file should be one of your priorities when it comes to WordPress security.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_Secure_Your_WordPress_File_Permissions\"><\/span>How to Secure Your WordPress File Permissions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Create a full backup of your website and database before modifying the permissions. The wrong setting can block WordPress access to critical files; make sure that you have the means of recovering from this.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_Setting_File_Permissions_Using_cPanel_or_FTP_Client\"><\/span>1. Setting File Permissions Using cPanel or FTP Client<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Your file permissions can be set using the <a href=\"https:\/\/harmonweb.com\/blog\/how-to-assign-permissions-to-files-and-folders-in-cpanel\/\" target=\"_blank\" rel=\"noopener\">cPanel File Manager tool<\/a> or the FTP client like <strong><span style=\"font-size: 10pt\">FileZilla<\/span><\/strong>.<\/p>\n<p>For changing the permissions via cPanel:<\/p>\n<ul style=\"list-style-type: square\">\n<li>Login to cPanel account.<\/li>\n<li>Go to File Manager and browse to the directory where WordPress is installed.<\/li>\n<li>Select the file or directory whose permissions you wish to change.<\/li>\n<li>Right-click on it and choose Change Permissions.<\/li>\n<li>Add the appropriate permissions number or choose the access options.<\/li>\n<li>Click the \u201cSave Changes\u201d button and make sure that your website is working properly.<\/li>\n<\/ul>\n<p>Using this technique, you should not assign the same permissions for all files and directories. Regular files, directories, and configuration files may need separate permissions.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_Changing_File_Permissions_via_SSH\"><\/span>2. Changing File Permissions via SSH<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: left\">Example:<\/p>\n<table class=\" aligncenter\" style=\"width: 70%;border-collapse: collapse\">\n<tbody>\n<tr>\n<td style=\"width: 100%\">\u00a0 chmod 644 wp-config.php<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>It will grant permissions for reading and writing for the file owner and permission for reading for all others. However, due to sensitive data stored in <strong><span style=\"font-size: 10pt\">wp-config.php<\/span><\/strong>, a stricter permission level like 400 or 440 would be more suitable.<\/p>\n<p>You can also use the following commands to set common permissions for ordinary WordPress files and directories:<\/p>\n<table style=\"border-collapse: collapse;width: 100%\">\n<tbody>\n<tr>\n<td style=\"width: 100%\">find \/path\/to\/wordpress\/ -type d -exec chmod 755 {} \\;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table style=\"border-collapse: collapse;width: 100%\">\n<tbody>\n<tr>\n<td style=\"width: 100%\">find \/path\/to\/wordpress\/ -type f -exec chmod 644 {} \\;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Use the correct path of your installation instead of \/<span style=\"font-size: 10pt\"><strong>path\/to\/wordpress\/<\/strong><\/span>. The above commands set permissions recursively, and hence they should be executed after thoroughly understanding what they do. It is especially important to look into sensitive files like <span style=\"font-size: 10pt\"><strong>wp-config.php<\/strong><\/span> file and impose restrictions on them after that.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_Protect_Your_WordPress_wp-configphp_File\"><\/span>How to Protect Your WordPress wp-config.php File<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>File permissions are very important, but there are other measures you could take to further limit access to the WordPress configuration file.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_Limiting_Access_to_wp-configphp\"><\/span>1. Limiting Access to wp-config.php<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Access to the <span style=\"font-size: 10pt\"><strong>wp-config.php<\/strong><\/span> file should be limited to just its owner and processes.<\/p>\n<p>400 or 440 permissions depend on where you are hosting the files. These permission settings give better security compared to the 644 permission setting.<\/p>\n<p>Nevertheless, ensure your web server can still read the file once the changes have been made. In case WordPress shows an error in connection to the configuration or database, undo the changes and revert to the previous permission setting.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_Move_wp-configphp_Outside_the_Public_Web_Root\"><\/span>2. Move wp-config.php Outside the Public Web Root<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>WordPress supports placing <strong><span style=\"font-size: 10pt\">wp-config.php<\/span><\/strong> one directory above the WordPress installation. This will give you one more level of security since the file won&#8217;t be inside the public website directory.<\/p>\n<p>For example, if your WordPress files are stored in:<\/p>\n<table class=\" aligncenter\" style=\"width: 85%;border-collapse: collapse\">\n<tbody>\n<tr>\n<td style=\"width: 100%\">\u00a0 \u00a0 \/home\/username\/public_html\/<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align: left\">You may be able to place the configuration file in:<\/p>\n<table class=\" aligncenter\" style=\"width: 90%;border-collapse: collapse\">\n<tbody>\n<tr>\n<td style=\"width: 100%\">\u00a0 \u00a0 \/home\/username\/wp-config.php<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Make sure that your hosting environment allows such an arrangement and WordPress can find the file. Make a backup copy of the original file before moving the file and then test the website.<\/p>\n<p>Moving the file is just another security measure, and not a substitute for strict permissions and configurations of the server.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"3_Prevent_Direct_Access_to_wp-configphp_from_Web_Browsers\"><\/span>3. Prevent Direct Access to wp-config.php from Web Browsers<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>If your website runs on an Apache server, you can use an <span style=\"font-size: 10pt\"><strong>.htaccess<\/strong><\/span> rule to deny direct HTTP requests to <a href=\"https:\/\/harmonweb.com\/blog\/how-to-monitor-php-error-logs-in-wordpress-and-cpanel\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-size: 10pt\"><strong>wp-config.php<\/strong><\/span><\/a>.<\/p>\n<p style=\"text-align: left\">Include the following directive in the <span style=\"font-size: 10pt\"><strong>.htaccess<\/strong><\/span> file:<\/p>\n<table class=\" aligncenter\" style=\"width: 60%;border-collapse: collapse\">\n<tbody>\n<tr>\n<td style=\"width: 100%\">&lt;Files &#8220;wp-config.php&#8221;&gt;<br \/>\nRequire all denied<br \/>\n&lt;\/Files&gt;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>This prevents visitors from requesting the configuration file directly through a browser. Place the rule outside the WordPress-managed rewrite section where possible.<\/p>\n<p>The directive shown is for Apache 2.4. Nginx servers require a different server-level configuration, so contact your hosting provider if you use Nginx or are unsure which web server your website runs on.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"4_Disable_File_Editing_from_the_WordPress_Dashboard\"><\/span>4. Disable File Editing from the WordPress Dashboard<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>WordPress allows administrators to edit plugin and theme PHP files through the dashboard by default. If an intruder gets hold of an admin account, this option may offer yet another avenue for getting a malicious code onto the site.<\/p>\n<p>The following line can be added to <span style=\"font-size: 10pt\"><strong>wp-config.php<\/strong><\/span> in order to turn off the native file editor feature:<\/p>\n<table style=\"border-collapse: collapse;width: 100%\">\n<tbody>\n<tr>\n<td style=\"width: 100%\">\u00a0 define( &#8216;DISALLOW_FILE_EDIT&#8217;, true );<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>It will disable the native file editing feature for themes and plugins from the dashboard. However, this is not a fail-safe against all types of file modifications but limits another avenue that attackers could use.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Common_File_Permission_Mistakes_to_Avoid\"><\/span>Common File Permission Mistakes to Avoid<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Once you have changed your WordPress file permissions, there are some common mistakes that may make your site vulnerable.<\/p>\n<ul style=\"list-style-type: square\">\n<li><strong>Files &amp; directories with <a href=\"https:\/\/harmonweb.com\/blog\/how-to-secure-your-wordpress-site-without-plugins\/\" target=\"_blank\" rel=\"noopener\">permission 777<\/a><\/strong>: It provides write permissions to all unnecessary users and poses a security threat.<\/li>\n<li><strong>Using similar permission in all cases<\/strong>: There is a difference between permission for files and directories.<\/li>\n<li><strong>Allowing wp-config.php permission without restrictions<\/strong>: Do not provide unnecessary read\/write permissions to this important file.<\/li>\n<li><strong>Overlooking ownership of the files<\/strong>: Even if you have correct permission numbers, having the <a href=\"https:\/\/harmonweb.com\/blog\/how-to-fix-wordpress-plugin-installation-failed-errors\/\" target=\"_blank\" rel=\"noopener\">wrong ownership of the files<\/a> might still be a problem.<\/li>\n<li><strong>Using restrictive settings too much<\/strong>: Restrictions on permissions may stop WordPress from accessing important files and result in website issues.<\/li>\n<li><strong>Permissions changes without a backup<\/strong>: You should always take a backup of your site before making any permission changes.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"How_to_Find_out_Whether_Your_WordPress_File_Permissions_Are_Secure\"><\/span>How to Find out Whether Your WordPress File Permissions Are Secure<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Checking file permissions frequently will assist you in discovering unnecessary accesses.<\/p>\n<p>It is recommended that you review your WordPress installation via <a href=\"https:\/\/harmonweb.com\/blog\/how-to-assign-permissions-to-files-and-folders-in-cpanel\/\" target=\"_blank\" rel=\"noopener\">cPanel File Manager<\/a>, FTP software, or SSH first. Regular files, directories, and the configuration files need to be examined independently.<\/p>\n<p>Pay particular attention to <span style=\"font-size: 10pt\"><strong>wp-config.php<\/strong><\/span>, the <strong><span style=\"font-size: 10pt\">wp-admin<\/span><\/strong> and <span style=\"font-size: 10pt\"><strong>wp-includes<\/strong><\/span> directories, and folders within <span style=\"font-size: 10pt\"><strong>wp-content<\/strong><\/span>. Note any unusual changes in permission and strange files and folders that offer unwanted write permission.<\/p>\n<p>In addition to that, ensure that the ownership of files is correct and also check that all major functionalities on your website work properly after making these changes. This includes checking if your dashboard loads fine and if you can upload media and make required updates on WordPress.<\/p>\n<p>If you find unexpected permission changes or strange files, investigate them rather than changing their permissions. These can be signs of an overall security issue that needs <a href=\"https:\/\/harmonweb.com\/blog\/what-to-do-when-google-says-your-website-contains-malware\/\" target=\"_blank\" rel=\"noopener\">malware detection<\/a> and more investigation.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Proper security of WordPress file permissions protects against any unauthorized people or operations accessing or altering your website\u2019s files. With proper file permissions and wp-config.php restriction along with restricting unnecessary file editing on dashboard, many security vulnerabilities can be avoided.<\/p>\n<p>Nonetheless, file permissions can never be relied on to provide absolute safety for your website. <a href=\"https:\/\/harmonweb.com\/hosting\/wp-hosting\" target=\"_blank\" rel=\"noopener\">Regular WordPress updates, strong administrator passwords, reliable backups and continuous security monitoring<\/a> are also important.<\/p>\n<h4><span class=\"ez-toc-section\" id=\"Are_You_Looking_for_Reliable_WordPress_Hosting\"><\/span>Are You Looking for Reliable WordPress Hosting?<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>The hosting environment is important in terms of your site\u2019s security. If you use WordPress for your website, at <a href=\"https:\/\/harmonweb.com\/\" target=\"_blank\" rel=\"noopener\">HarmonWeb<\/a>, you will be provided with quality WordPress hosting that will fulfill the needs of your website.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>File permissions in WordPress are an important factor in safeguarding the website against attacks. When the settings of&hellip;<\/p>\n","protected":false},"author":25,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"footnotes":""},"categories":[158],"tags":[],"class_list":["post-8533","post","type-post","status-publish","format-standard","hentry","category-troubleshooting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Secure WordPress File Permissions and Protect Your wp-config.php File | HarmonWeb<\/title>\n<meta name=\"description\" content=\"Learn how to secure WordPress file permissions, protect your wp-config.php file, restrict unauthorized access and reduce common website security risks.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Secure WordPress File Permissions and Protect Your wp-config.php File | HarmonWeb\" \/>\n<meta property=\"og:description\" content=\"Learn how to secure WordPress file permissions, protect your wp-config.php file, restrict unauthorized access and reduce common website security risks.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/\" \/>\n<meta property=\"og:site_name\" content=\"HarmonWeb\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-28T05:32:32+00:00\" \/>\n<meta name=\"author\" content=\"Adediran Samuel\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Adediran Samuel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/secure-wordpress-file-permissions\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/secure-wordpress-file-permissions\\\/\"},\"author\":{\"name\":\"Adediran Samuel\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#\\\/schema\\\/person\\\/e5ecdeaa5be92fe77baabab9b5080c1c\"},\"headline\":\"How to Secure WordPress File Permissions and Protect Your wp-config.php File\",\"datePublished\":\"2026-11-28T05:32:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/secure-wordpress-file-permissions\\\/\"},\"wordCount\":1970,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#organization\"},\"articleSection\":[\"Troubleshooting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/harmonweb.com\\\/blog\\\/secure-wordpress-file-permissions\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/secure-wordpress-file-permissions\\\/\",\"url\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/secure-wordpress-file-permissions\\\/\",\"name\":\"How to Secure WordPress File Permissions and Protect Your wp-config.php File | HarmonWeb\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#website\"},\"datePublished\":\"2026-11-28T05:32:32+00:00\",\"description\":\"Learn how to secure WordPress file permissions, protect your wp-config.php file, restrict unauthorized access and reduce common website security risks.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/secure-wordpress-file-permissions\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/harmonweb.com\\\/blog\\\/secure-wordpress-file-permissions\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/secure-wordpress-file-permissions\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Secure WordPress File Permissions and Protect Your wp-config.php File\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/\",\"name\":\"HarmonWeb\",\"description\":\"Web Hosting In Nigeria\",\"publisher\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Organization\",\"Place\"],\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#organization\",\"name\":\"HarmonWeb\",\"url\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/\",\"logo\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/secure-wordpress-file-permissions\\\/#local-main-organization-logo\"},\"image\":{\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/secure-wordpress-file-permissions\\\/#local-main-organization-logo\"},\"telephone\":[],\"openingHoursSpecification\":[{\"@type\":\"OpeningHoursSpecification\",\"dayOfWeek\":[\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\",\"Sunday\"],\"opens\":\"09:00\",\"closes\":\"17:00\"}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/#\\\/schema\\\/person\\\/e5ecdeaa5be92fe77baabab9b5080c1c\",\"name\":\"Adediran Samuel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/wp-content\\\/litespeed\\\/avatar\\\/7094e9183d0321d5656817fbeb1f491d.jpg?ver=1795804450\",\"url\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/wp-content\\\/litespeed\\\/avatar\\\/7094e9183d0321d5656817fbeb1f491d.jpg?ver=1795804450\",\"contentUrl\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/wp-content\\\/litespeed\\\/avatar\\\/7094e9183d0321d5656817fbeb1f491d.jpg?ver=1795804450\",\"caption\":\"Adediran Samuel\"},\"url\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/author\\\/adediran-samuel\\\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/secure-wordpress-file-permissions\\\/#local-main-organization-logo\",\"url\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/cropped-HARMON-WEB-LOGO-2.png\",\"contentUrl\":\"https:\\\/\\\/harmonweb.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/cropped-HARMON-WEB-LOGO-2.png\",\"width\":831,\"height\":172,\"caption\":\"HarmonWeb\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Secure WordPress File Permissions and Protect Your wp-config.php File | HarmonWeb","description":"Learn how to secure WordPress file permissions, protect your wp-config.php file, restrict unauthorized access and reduce common website security risks.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/","og_locale":"en_US","og_type":"article","og_title":"How to Secure WordPress File Permissions and Protect Your wp-config.php File | HarmonWeb","og_description":"Learn how to secure WordPress file permissions, protect your wp-config.php file, restrict unauthorized access and reduce common website security risks.","og_url":"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/","og_site_name":"HarmonWeb","article_published_time":"2026-11-28T05:32:32+00:00","author":"Adediran Samuel","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Adediran Samuel","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#article","isPartOf":{"@id":"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/"},"author":{"name":"Adediran Samuel","@id":"https:\/\/harmonweb.com\/blog\/#\/schema\/person\/e5ecdeaa5be92fe77baabab9b5080c1c"},"headline":"How to Secure WordPress File Permissions and Protect Your wp-config.php File","datePublished":"2026-11-28T05:32:32+00:00","mainEntityOfPage":{"@id":"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/"},"wordCount":1970,"commentCount":0,"publisher":{"@id":"https:\/\/harmonweb.com\/blog\/#organization"},"articleSection":["Troubleshooting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/","url":"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/","name":"How to Secure WordPress File Permissions and Protect Your wp-config.php File | HarmonWeb","isPartOf":{"@id":"https:\/\/harmonweb.com\/blog\/#website"},"datePublished":"2026-11-28T05:32:32+00:00","description":"Learn how to secure WordPress file permissions, protect your wp-config.php file, restrict unauthorized access and reduce common website security risks.","breadcrumb":{"@id":"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/harmonweb.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Secure WordPress File Permissions and Protect Your wp-config.php File"}]},{"@type":"WebSite","@id":"https:\/\/harmonweb.com\/blog\/#website","url":"https:\/\/harmonweb.com\/blog\/","name":"HarmonWeb","description":"Web Hosting In Nigeria","publisher":{"@id":"https:\/\/harmonweb.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/harmonweb.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Organization","Place"],"@id":"https:\/\/harmonweb.com\/blog\/#organization","name":"HarmonWeb","url":"https:\/\/harmonweb.com\/blog\/","logo":{"@id":"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#local-main-organization-logo"},"image":{"@id":"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#local-main-organization-logo"},"telephone":[],"openingHoursSpecification":[{"@type":"OpeningHoursSpecification","dayOfWeek":["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],"opens":"09:00","closes":"17:00"}]},{"@type":"Person","@id":"https:\/\/harmonweb.com\/blog\/#\/schema\/person\/e5ecdeaa5be92fe77baabab9b5080c1c","name":"Adediran Samuel","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/harmonweb.com\/blog\/wp-content\/litespeed\/avatar\/7094e9183d0321d5656817fbeb1f491d.jpg?ver=1795804450","url":"https:\/\/harmonweb.com\/blog\/wp-content\/litespeed\/avatar\/7094e9183d0321d5656817fbeb1f491d.jpg?ver=1795804450","contentUrl":"https:\/\/harmonweb.com\/blog\/wp-content\/litespeed\/avatar\/7094e9183d0321d5656817fbeb1f491d.jpg?ver=1795804450","caption":"Adediran Samuel"},"url":"https:\/\/harmonweb.com\/blog\/author\/adediran-samuel\/"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/harmonweb.com\/blog\/secure-wordpress-file-permissions\/#local-main-organization-logo","url":"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2020\/06\/cropped-HARMON-WEB-LOGO-2.png","contentUrl":"https:\/\/harmonweb.com\/blog\/wp-content\/uploads\/2020\/06\/cropped-HARMON-WEB-LOGO-2.png","width":831,"height":172,"caption":"HarmonWeb"}]}},"_links":{"self":[{"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/posts\/8533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/comments?post=8533"}],"version-history":[{"count":4,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/posts\/8533\/revisions"}],"predecessor-version":[{"id":8558,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/posts\/8533\/revisions\/8558"}],"wp:attachment":[{"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/media?parent=8533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/categories?post=8533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/tags?post=8533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}