Strange redirects, spammy pages in Google, a warning from your browser, or a message from your host about malware. Finding out your website has been hacked is stressful, but it's recoverable. The key is to work through it calmly and properly, so the attacker doesn't get straight back in.
Signs your site may be hacked
- Visitors are redirected to spam, scam or adult sites, sometimes only on mobile or only from search results
- Google shows a warning ("This site may be hacked") or strange titles in search results
- Unknown pages, posts or users appear in WordPress
- Your browser or antivirus blocks the site
- Your host reports malware or outgoing spam
- Your site is suddenly very slow or hitting resource limits
- Files you don't recognize appear in your hosting account
Step 1: Don't panic, and don't delete everything
Deleting your whole site in a hurry can destroy evidence you need to find out how the attacker got in, and the clean content you want to keep. Take a breath and work step by step.
Step 2: Contact your host
Tell your host what you're seeing, when it started and any recent changes. They can check server-side logs and malware scanning results, and help with restores.
Step 3: Change your passwords
Assume passwords may be compromised. Change them, from a device you trust:
- Hosting client area
- Control panel (cPanel or DirectAdmin)
- WordPress administrator accounts. Also check for and remove any admin users you don't recognize.
- FTP and SSH accounts
- Database users (then update
wp-config.phpwith the new database password) - Email accounts on the domain
Turn on two-factor authentication where you can. See strong passwords and two-factor authentication.
Step 4: Scan your own computer
If your computer has malware, it could have captured your passwords. Run a full scan with up-to-date security software before relying on new passwords.
Step 5: Back up the hacked site
Yes, really. Take a copy of the current files and database before you change anything. It's useful for working out what happened, and as a safety net in case a cleanup removes something you need. Store it off the server and label it clearly as infected.
Step 6: Choose: restore or clean
Option A: Restore a clean backup
If you have a backup from before the hack, restoring it is often the fastest fix.
- Your host's automatic backups may go back far enough. Check your control panel for a restore tool such as JetBackup, or ask your host.
- Choose a date before the first sign of trouble. Attackers sometimes plant code days before they use it.
Restoring alone isn't enough. If you don't fix how they got in, they'll come back. Continue with Steps 7 and 8.
Option B: Clean the site
If there's no clean backup, or the hack is older than your backups:
- Replace WordPress core files with fresh copies of the same version: everything except
wp-contentandwp-config.php. - Reinstall plugins and themes from official sources, rather than trying to clean them file by file.
- Check
wp-content/uploadsfor PHP files. Uploads should contain media, not code. - Inspect
wp-config.phpand.htaccessfor unfamiliar code, redirects or includes. - Check the database for injected scripts in posts and options, and for unknown admin users.
- Look for recently modified files with File Manager's date column.
Cleaning thoroughly takes care and some technical skill. If you're not comfortable doing it, a professional malware cleanup service is worth the cost.
Step 7: Find and close the hole
Common entry points:
- An outdated plugin or theme with a known vulnerability (the most common)
- A nulled (pirated) plugin or theme
- A weak or reused password
- An abandoned plugin, no longer maintained
- A forgotten old site, test copy or staging site in the same account
Update everything, delete anything unused, and remove old copies of sites you don't need. Our WordPress security checklist covers the rest.
Step 8: Clean up after-effects
- Google: if Search Console shows security issues, fix them and request a review. Also remove spam pages that Google indexed, using redirects or by letting them return 404 or 410.
- Email reputation: if your account sent spam, check whether your domain or server was blacklisted. See why your emails go to spam.
- Visitors and customers: if any personal data may have been exposed, you may have legal obligations to tell people. Get advice if you're unsure.
Step 9: Monitor closely for a few weeks
Re-infections are common if a backdoor was missed. For the next few weeks:
- Run security scans regularly
- Watch for new admin users or unfamiliar files
- Keep an eye on Search Console and uptime monitoring
Preventing the next one
- Keep WordPress, plugins and themes updated
- Use strong passwords and 2FA
- Install only trusted plugins and delete unused ones
- Keep regular, off-site backups. See the 3-2-1 backup rule for websites
- Don't leave old sites and backup files in your hosting account
The bottom line
If your site is hacked: contact your host, change passwords, back up what's there, restore or clean the site, and close the hole that let the attacker in. Then monitor closely. With good updates, strong logins and solid backups, it's much less likely to happen again.