Skip to content

How to Remove Malware From a WordPress Site: Manually, With a Plugin, or at Server Level

On this page

Last updated: · By

Short answer: there are three ways to remove malware from a WordPress site: clean it by hand (replace core and plugin files with official copies and hunt for foreign code in the database), use a security plugin that scans and cleans from inside WordPress, or use automatic server-level cleaning that runs outside your site. Manual cleanup is free but takes know-how and hours. A plugin is convenient, but it runs on the same layer the malware runs on. Server-level protection, like Cloudways Malware Protection at $2 to $4 per application per month, also cleans the database and keeps protecting the site after the cleanup.

⏱ Time needed: 30 minutes (server-level cleanup) to 4–8 hours (manual cleanup) · Difficulty: intermediate to advanced · Last checked: 6 Nov 2026

What “a virus on your site” really means, and why it is so hard to get rid of

Malware on a website is code that was inserted without permission and does something you never asked for. On WordPress sites it usually shows up in one of four forms:

  • Backdoor: a small PHP file that lets the attacker come back even after you change your passwords. It is the most important thing to clean, and the easiest to miss.
  • Malicious redirect: sends visitors to another site, sometimes only from mobile or from Google.
  • SEO spam: thousands of hidden pages or links that exploit your domain’s authority in Google.
  • Data theft: a script on the checkout page that copies card details, or code that steals user passwords.

Malware is hard to clean for two reasons. First, it spreads: there are several copies in different places, and some of them live in the database rather than in files. Second, if the door they came through (a vulnerable plugin, a leaked password) stays open, the site gets reinfected within days. For an example, see what a WP File Manager hack on Cloudways looks like and what to do afterwards.

Before you start cleaning

  • Isolate the site and save a copy of its current state, as explained in the emergency guide for a hacked site. If you haven’t done that yet, start there.
  • Change every password: hosting account, SFTP/SSH, WordPress admin users, the database and email.
  • Check whether you have a backup from before the hack. If you do, restoring it may be faster than cleaning (see backup and restore on Cloudways).
  • Make sure you have SFTP or SSH access to the server. Cleaning only through the WordPress dashboard does not reach every file.

Which way of removing malware from a site should you choose?

Manual cleanupSecurity pluginServer-level cleanup
CostFree (your time)Free versions exist. Paid cleanup services, for example Sucuri from $229 per year (official site, 6 Nov 2026)Malware Protection on Cloudways: $4 per application per month (1–5), $3 (6–15), $2 (16 and above)
Skills neededHigh: SSH, WP-CLI, SQLLowLow
TimeHoursMinutes to an hour for a scanThe first scan starts as soon as you enable it
DatabaseOnly if you search it yourselfDepends on the pluginYes, for WordPress, Joomla and Magento
Can malware disable it?Not applicableYes, it runs inside WordPressNo, it runs outside your site
Protection after cleanupNoneYes, as long as the plugin is activeYes, including runtime blocking (RASP)
Best forDevelopers, small sites, zero budgetAny hosting, including sharedAnyone hosting on a Cloudways Flexible server

There is no single “best” option. If you are on shared hosting and don’t plan to move, a plugin is the practical choice. If you manage several sites on your own server, server-level cleanup saves the most time. And if you are a developer who wants to understand what happened, manual cleanup teaches you the most.

Way 1: manual cleanup of a WordPress site, step by step

The core idea: don’t try to find every malicious line. Replace everything you can replace with a clean official copy, and search by hand only through what you can’t replace (your content, the uploads and the database). The commands here are WP-CLI, which is available on Cloudways servers over SSH (see connecting over SSH and the WP-CLI guide).

  1. Check the core files against the official version: wp core verify-checksums. Any file reported as different or unexpected is suspicious.
  2. Replace the core with a clean copy without touching your content: wp core download --force --skip-content. The command downloads the WordPress files again and leaves wp-content and wp-config.php alone.
  3. Check the plugins: wp plugin verify-checksums --all compares plugins against the official repository. Reinstall any plugin that fails the check. Premium plugins should only be re-downloaded from the vendor’s own site.
  4. Delete unused plugins and themes, and anything downloaded from an unofficial source (a “nulled” version of a paid plugin).
  5. Look for PHP files in the uploads folder: find wp-content/uploads -name "*.php". There should be no PHP files in that folder. Any result is almost certainly malicious.
  6. Go through the active theme’s files, mainly functions.php, header.php and footer.php. Search for eval(, base64_decode( and long unreadable strings. If the theme comes from the official repository, just reinstall it.
  7. Check .htaccess in the root folder and in subfolders. RewriteCond rules that look at where the visitor came from (Referrer) or which browser they use (User-Agent) are a clear sign of a malicious redirect.
  8. Search the database for injected scripts: wp db search '<script' --all-tables. Also check the siteurl and home values in the options table.
  9. Check users and scheduled tasks: wp user list --role=administrator and wp cron event list. Delete administrators you don’t recognize and tasks with odd names.
  10. Replace the security keys (salts) in wp-config.php: wp config shuffle-salts. This logs out everyone who is currently signed in, the attacker included.

Before deleting anything, make sure you have a copy. And on a WooCommerce store, don’t run search-and-replace commands on the database without a fresh backup: one mistake in a search-and-replace is enough to break orders.

Way 2: cleaning with a security plugin

Security plugins like Wordfence and Sucuri offer a scanner that compares your files against official copies and looks for signatures of known malware. Some also offer a paid cleanup service done by their team. The advantage: it works on any hosting, shared hosting included, and needs no SSH.

The structural weakness: the plugin runs inside WordPress, on the same layer as the malware. Malware with write permissions can disable the plugin, modify it, or hide from its scan. Cloudways makes the same argument for server-level protection, and it holds true regardless of the vendor. On top of that, a full scan of a large site uses server resources, on the site itself.

If you chose a plugin: run a full scan, deal with every finding (if the plugin isn’t sure, don’t delete a core file, reinstall it), and then go through steps 4, 5 and 9 of the manual cleanup. A plugin doesn’t always find PHP files in the uploads folder or users that were added.

Way 3: server-level cleanup with Cloudways Malware Protection

Malware Protection is a paid add-on for Cloudways Flexible servers, built on Imunify360. It runs at the server level, so code planted in your site can’t turn it off. It scans files and the database, cleans automatically, and sends a report. As of November 2026 the price is per application per month: $4 for 1 to 5 applications, $3 for 6 to 15, and $2 from 16 up.

  1. Log in to the management panel, open Servers and choose the server your site lives on.
  2. Click the www icon (the globe) and choose the application.
  3. Under Application Management, choose Application Security → Malware Protection. Already here you can see whether the application is marked as Infected.
  4. Click Enable Protection. Real-time protection is switched on, and the first scan of the files and database starts automatically. You don’t need to keep the panel open.
  5. When the scan finishes, go to the Malicious tab. Every finding appears with a status: Cleaned (the code was removed from inside the file), Removed (the whole malicious file was deleted), Quarantined (isolated, and can be restored) or In Progress.
  6. Go through the list. If a legitimate file was flagged by mistake, restore it from the Actions column. The restore is automatically reported as a “False Positive” for review. Check with your developer before restoring anything.
  7. Check Scan History and Proactive Defense. The second shows attempts that were blocked at runtime, including the script path they came from. That is a good hint to where the hole is.

Two important things to know. First, if the automatic cleanup doesn’t succeed, you open a support ticket, and according to Cloudways its security analysts clean manually at no extra charge. Second, the add-on does not give you a full investigation of how the attacker got in. Cloudways says so explicitly. Closing the hole is still your job (see below). To get the warning removed from Google, see Google’s “this site may harm your computer” warning.

One more clarification: malware detection is included for free on Flexible servers. What you pay for is the automatic cleanup, the runtime protection and the database scan. You can enable the add-on only on selected sites. Full setup guide: Malware Protection on Cloudways. Prices of all add-ons: add-on pricing.

Black Friday80% off
80% off 2 months of managed hosting

The code BFCM802 takes 80% off your bill for the first two months (up to $200 off per month), including unlimited free site migrations. New customers only, and only until the offer ends.

The offer ends on December 4, 2026 at 23:59 (UTC+2).

Ends in—days—hours—minutes—seconds
Code:
Grab the 80% now

Start with a free trial, no credit card. Enter the code at checkout and check that it shows up.

After Black Friday: 30% off for 3 months with the code ASAEL. On a large server (above about $444 a month) ASAEL already saves more today. BFCM802 vs. ASAEL calculator

How do you make sure the site is really clean afterwards?

Verify it systematically, because a cleanup you haven’t checked is a guess. After any of the three ways, go through this list:

  • Run another scan. A new finding a day or two later means the backdoor is still there.
  • Visit the site from a mobile phone, from an incognito window and through a Google result. Those are the scenarios malware tends to target.
  • Search Google for site:yourdomain.com and check whether any spam pages are left in the index.
  • Check the Security issues report in Google Search Console, and if there is a warning, submit a review request.
  • Close the hole: update everything, check the Vulnerability Scanner in the panel (under Application Security), and turn on two-factor authentication.

When to call a professional

There are situations where you shouldn’t clean the site yourself: when the site processes payments and card theft is a possibility, when the site gets reinfected after two cleanups, when you suspect customers’ personal data leaked, or when you simply don’t have time to learn this under pressure. A security specialist will also look for the entry point, which is the part automated tools don’t do. For cleaning up and recovering after spam, see the Japanese keyword hack and spam pages in the index.

What mistakes do people commonly make when removing malware from a site?

Cleaning without changing passwords: the attacker comes back with the old password. Change them first, clean afterwards.

Deleting only the suspicious file: malware almost always leaves several copies. After you find one file, search for the same string across the whole site.

Forgetting the database: redirects and scripts injected into posts and settings won’t show up in a file scan.

Installing another security plugin on top of an existing one: two scanners running at once slow the site down and can conflict. Pick one.

Restoring a file flagged as malicious “because the site broke”: sometimes it really is a false positive, and sometimes the theme itself is infected. Check the code before you restore it.

Black Friday80% off
80% off 2 months of managed hosting

The offer ends on December 4, 2026 at 23:59 (UTC+2).

Code:
Grab the 80% now

Start with a free trial, no credit card. Enter the code at checkout and check that it shows up.

Frequently asked questions

How do I remove malware from WordPress without losing my rankings?

Clean fast, return a 404 or 410 for the spam pages that were added, and ask Google for a review in Search Console. Your real pages haven’t changed, so rankings usually recover once the warning is removed. What really hurts rankings is leaving the site infected for a long time.

Is a free security plugin enough to clean a site?

Sometimes, for a simple hack. But a plugin runs inside WordPress, and malware with write permissions can disable it. After the scan, manually check the uploads folder for PHP files, admin users and the database.

How much does it cost to remove malware from a site?

Manual cleanup costs only your time. On Cloudways, Malware Protection costs $2 to $4 per application per month, and includes manual cleanup by support if the automatic one fails. External cleanup services, such as Sucuri’s, start at hundreds of dollars a year.

Why was my site reinfected after I cleaned it?

Because the hole is still open or a backdoor is still there. The usual causes: a vulnerable plugin that wasn’t updated, a password that wasn’t changed, or a malicious file that wasn’t found. Change passwords, update everything and replace the security keys in wp-config.php.

Does Cloudways Malware Protection slow down the site?

According to Cloudways, the performance impact is negligible, because the scan runs at the server level and not inside WordPress. It notes that noticeable resource use may appear only on a small server with a huge number of files.

Can I use Malware Protection and a security plugin together?

Yes, they shouldn’t conflict, because Malware Protection blocks requests at the server level before they reach the plugins. Cloudways recommends moving fully to server-level protection, but the decision is yours. If you keep a plugin, turn off its heavy scanning to save resources.

Sources

Official source: How to Use Malware Protection to Protect Your Applications, Detect Security Bugs Using Vulnerability Scanner (Cloudways Knowledge Base); Cloudways Malware Protection; Sucuri pricing (checked 6 Nov 2026); WP-CLI: wp core verify-checksums. This guide was written and checked by Asael Dreyer · Updated: 6 Nov 2026

Disclosure: this is an independent site, not the official Cloudways site. Some links on this site are affiliate links: if you sign up through them we earn a commission, at no extra cost to you. Full details

Picture of Asael Dreyer
Asael Dreyer

Hi, I'm Asael Dreyer, CEO of an SEO agency that runs hundreds of websites hosted on dozens of Cloudways servers.
Everything you will find here comes from hands-on experience, mine and my teams', straight from the field: from the guides to the recommendations. All to help you get the most out of Cloudways.

More about me →

Need help? Got a question about your server or this guide? Write to us and we will get back to you.

More guides on this topic:
מפריד
Thanks for your message!
We will get back to you soon.
Ready to get started?

Sign up with the coupon code ASAEL