Security · Guide
How to Harden WordPress on Shared Hosting
Short answer
To harden WordPress on shared hosting, update WordPress, themes and plugins, set folders to 755 and files to 644, protect wp-config.php at 400 or 440, disable the built-in file editor, turn on two-factor authentication, and add a firewall. Shared hosting adds one risk you cannot fix alone: a hacked site on the same server can reach yours, so pick a host that isolates accounts.
Key takeaways
- Only the latest WordPress version gets security updates, so update core, plugins and themes and delete what you do not use.
- Set folders to 755, files to 644 and wp-config.php to 400 or 440; never use 777.
- Add define('DISALLOW_FILE_EDIT', true); to wp-config.php to remove the dashboard file editors.
- Turn on two-factor authentication for every admin account and use SFTP, not FTP.
- Back up files plus database at least weekly, keep a copy off the server, and test a restore.
What does hardening WordPress on shared hosting mean?
Hardening WordPress on shared hosting means tightening settings, file access and logins so one weak point cannot hand an attacker your whole site.
WordPress.org's hardening guide frames security as risk reduction, not risk elimination. You add controls that lower the odds of an attack and limit the damage if one lands.
On shared hosting you control WordPress, not the server. Your host runs the server software, while you own updates, passwords, file access and plugins.
Hardening covers four areas:
- Updates for WordPress core, plugins, themes and PHP
- File permissions and wp-config.php
- Logins, user roles and wp-admin
- Backups and a firewall
Why is shared hosting harder to secure than other hosting?
Shared hosting is harder to secure because your site shares a server with other sites, so a breach next door can put your site at risk.
WordPress.org's hardening guide warns that if a site on the same shared server is compromised, your site can be compromised too, even if you followed the guide. Ask your host what isolation it uses between accounts.
You also cannot install server tools or change server settings. That rules out some defenses, such as a server firewall you control, and leaves you with WordPress-level controls and services that sit in front of your site.
The fix is to pick a host that runs each account under its own username. WordPress.org's requirements page says hosting is more secure when PHP runs under your account username instead of a shared server username.
What should you update first?
Update WordPress core first, then plugins and themes, and delete anything you do not use.
WordPress.org's hardening guide states that only the latest WordPress version is maintained with security updates. Older versions stop getting fixes, and details of fixed flaws become public, so old versions get easier to attack over time.
Automatic updates have existed since WordPress 3.7. Turn on auto-updates for core, plugins and themes in your dashboard, or update by hand each week and never let an update sit for a month.
Plugins carry most of the risk. Patchstack counted 11,334 new WordPress vulnerabilities in 2025, and 91% of them were in plugins, with only 6 in WordPress core, according to its State of WordPress Security in 2026 report.
Check your PHP version too. WordPress.org recommends PHP 8.3 or newer, with MySQL 8.4 or MariaDB 10.11 or newer, on its requirements page.
If your host still runs an old PHP version, follow this guide to update PHP in WordPress.
How do you set safe file permissions?
Set folders to 755, files to 644, and wp-config.php to 400 or 440.
WordPress.org's hardening guide gives this exact scheme. When WordPress runs an automatic update, it sets files to 0644 and folders to 0755 by itself.
| Path | Permission | Who can write |
|---|---|---|
| Folders | 755 | Owner only |
| Files | 644 | Owner only |
| wp-config.php | 400 or 440 | Owner only |
| wp-content/uploads | 755 | Owner and web server |
Never use 777. That setting lets anyone on the server write to the file, which is the widest opening you can give an attacker.
In cPanel, open File Manager, right-click a folder or file, choose Change Permissions, and type the number. With shell access, the hardening guide gives these commands:
find /path/to/your/wordpress/install/ -type d -exec chmod 755 {} \;
find /path/to/your/wordpress/install/ -type f -exec chmod 644 {} \;
Check permissions again after installing a plugin. Some installers loosen them, and a monthly check catches that drift.
How do you lock down wp-config.php?
Lock down wp-config.php by tightening its permissions, blocking web access to it, and switching off the dashboard file editor.
The file holds your database password and secret keys, so WordPress.org's hardening guide says only you and the web server should read it, which means a 400 or 440 permission.
You can also move wp-config.php one folder above your WordPress install, outside the web root. WordPress looks one level up for the file on its own, and the guide notes some experts dispute how much this helps.
Block direct web access by adding a rule at the very top of your .htaccess file. The rule names wp-config.php in a Files block and sets Require all denied, so any browser request for the file is refused.
Add this line to wp-config.php, before the line that says stop editing, to remove the dashboard theme and plugin editors:
define( 'DISALLOW_FILE_EDIT', true );
The guide notes this removes the edit_themes, edit_plugins and edit_files capabilities from every user. It will not stop an attacker uploading files, but it closes one route after an admin account is taken over.
How do you protect logins and wp-admin?
Protect logins with long unique passwords, two-factor authentication, and a second password layer on wp-admin where your host allows it.
WordPress.org's hardening guide says a strong password matters because an attacker with an admin account can install scripts that compromise the whole server. Avoid your name, your site name, dictionary words and short passwords.
Turn on two-factor authentication for every admin account. WordPress core does not include it, so use a plugin or your host's option. Wordfence adds TOTP two-factor authentication, login CAPTCHA and passkeys, as listed on its WordPress.org plugin page.
Rename the default admin account. The hardening guide lists admin and webmaster as the first usernames attackers try, so avoid easily guessed names.
WordPress has six built-in roles, and the Subscriber role has only the read capability. Give each person the lowest role that fits their job, and remove accounts nobody uses. The full list is on the roles and capabilities page.
Use SFTP instead of FTP to reach your server. The hardening guide notes SFTP encrypts your password in transit, while FTP sends it in the clear.
Should you add a firewall on shared hosting?
Yes, add a firewall, because on shared hosting it is the main defense that sits between attackers and your WordPress install.
The hardening guide names three layers: a plugin firewall, a server firewall such as ModSecurity, and a cloud firewall that filters traffic before it reaches your host. Cloudflare, Sucuri and Imperva are the examples it gives.
A plugin firewall runs inside WordPress. Wordfence's free version includes a firewall and a scanner that checks files against more than 44,000 known malware variants. Its free Threat Defense Feed updates are delayed by 30 days, while paid plans get them in real time.
A cloud firewall also shields you from traffic floods. Cloudflare's DDoS protection runs on all plans, including free, with unmetered standard protection across layers 3 to 7, according to its DDoS protection docs.
Set up the plugin firewall with this guide to set up the Wordfence firewall. Pick one plugin firewall and one cloud service at most, since two plugin firewalls can clash and slow the site.
What should you back up, and how often?
Back up the full site, files plus database, at least weekly, and keep one copy off the server.
The hardening guide calls backups part of preparation: a sound plan keeps timed snapshots of the whole install in a trusted place. If a hack is found days later, a pre-hack snapshot is what lets you rebuild cleanly.
Test a restore at least once. A backup you never restored is a guess, not a safety net. If you use UpdraftPlus, follow this guide to restore a backup with UpdraftPlus.
Encrypt backup files or store them where only you can read them. The guide notes that encrypted backups and hash records raise confidence the data was not tampered with.
How do you check that the hardening worked?
Check the work with a scan, a permissions review and a login test, then repeat the checks on a schedule.
Run a vulnerability scan with WPScan, a free scanner for non-commercial use. Its free API token allows 25 requests a day, and it checks your WordPress version, plugins, themes and usernames against its vulnerability database. See the WPScan documentation for the install steps.
Open your site in a private browser window and try to reach wp-config.php and readme.html directly. Both requests should fail.
Check Site Health in your dashboard under Tools, then Site Health. It flags outdated PHP, missing HTTPS and other gaps in plain language.
Repeat the scan monthly. New flaws appear every week, so a clean scan today says nothing about next month.
What mistakes should you avoid?
The common mistakes are leaving updates for later, using 777 permissions, and trusting one plugin to do all the work.
Avoid these five:
- Installing plugins from outside the WordPress.org directory or a known vendor
- Keeping deactivated plugins on the server, since their code is still there
- Using admin as a username
- Skipping backups until after a problem
- Leaving debug output on in production
The hardening guide warns against plugins from untrusted sources: get plugins and themes only from the WordPress.org directory or known companies.
If hardening keeps failing, or your host cannot isolate accounts, it is time to move. See when to upgrade from shared hosting for the signs.
Frequently asked questions
Can I harden WordPress on shared hosting without a plugin?
Yes. Updates, file permissions, wp-config.php constants, strong passwords, SFTP and tested backups all need no plugin. A firewall plugin or cloud firewall adds a layer on top, but the core steps are settings and habits, not software.
Is 777 ever safe for a WordPress folder?
No. A 777 permission lets anyone on the server write to that folder, including other accounts on shared hosting. WordPress.org's guide recommends 755 for folders and 644 for files, with wp-config.php at 400 or 440.
Does hardening slow down my site?
The settings in this guide do not slow a site. A firewall plugin adds a small load, and a cloud firewall usually speeds the site up by caching and filtering bad traffic before it reaches your server.
How often should I repeat the hardening checks?
Check for updates weekly, review file permissions and user accounts monthly, and run a full vulnerability scan monthly. Re-check everything at once after any major change, such as a host move or a new plugin.
What should I do first if my shared hosting account was hacked?
Change every password, restore from a clean backup made before the hack, update everything, and scan for leftover files. Tell your host, since the same server may hold other affected sites, and check whether the attack spread through a shared account.
Sources
- Hardening WordPress WordPress Developer Resources
- Requirements WordPress.org
- Roles and Capabilities WordPress.org
- Wordfence Security WordPress.org
- Patchstack Patchstack
- Installing WPScan WPScan
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.
Thanks — we review requests within 3 business days.
