Guide SSL & Security

What to do first if your website is hacked

A calm, ordered checklist for the first hour: contain it, change every credential, restore clean, then find how it got in.

Updated 10 min read Intermediate

If you have just confirmed your website has been compromised, work through this in order rather than jumping to whichever step feels most urgent. The sequence matters: acting out of order can waste the evidence you need to stop it happening again, or bring a still-compromised site back online before it is actually safe to.

1. Take the site offline or into maintenance mode

A live, compromised site keeps doing damage for as long as it stays reachable — serving malware to visitors, sending spam, or feeding search engines content you did not write. Putting the site into maintenance mode or taking it offline entirely stops the bleeding while you work, and it does not need to be a permanent step.

Before you change anything, note what you can

If you have a moment before rushing into cleanup, jot down what first alerted you and when — an unfamiliar file's modification date, a warning email, a visitor report. This small piece of context makes step five, working out how it happened, considerably easier once the immediate pressure is off.

2. Change every credential, immediately

Assume everything was potentially exposed and change it, in this order:

  • Your control panel password. This is the account with the widest reach across your hosting, so secure it first.
  • CMS admin passwords. Every administrator account, not just the one you normally use.
  • Database password. Update it in both the database itself and wherever your site's configuration references it, or the site will stop connecting.
  • FTP and SSH credentials. Anything that could have provided file-level access.
Turn on two-factor authentication while you are in there

If it is not already enabled on your control panel and CMS admin accounts, this is the moment to add it — see how to turn on two-factor authentication. It stops a reused or previously leaked password being enough on its own next time.

3. Find the most recent clean backup

Restoring from a backup taken before the compromise is almost always faster and more reliable than trying to identify and clean every affected file individually — a compromise often touches more files than are obvious from a manual look. Check the dates available and identify the most recent backup that predates when you believe the compromise started.

Do not restore blindly to the most recent backup without checking the date

If the backup you restore was itself taken after the compromise began, you will restore the problem along with everything else. Cross-reference the backup date against whatever first alerted you — an unfamiliar file's modification date, a warning email, a report from a visitor.

4. No clean backup? Clean it manually

Without a backup that predates the compromise, every file needs checking individually rather than trusted wholesale. How to scan your site for malware covers running a proper scan, and treat any file the scan flags, plus anything with a modification date matching the suspected compromise window, as needing removal or replacement from a known-good source.

5. Find out how it happened

This step is easy to skip when you are relieved the site is working again, and it is the single most important one. Common causes worth checking specifically:

  • An outdated CMS, plugin or theme with a known, published vulnerability.
  • A weak or reused password on an admin, FTP or database account.
  • A file or folder left with overly permissive access — see how to set safe file permissions for what correct permissions actually look like.
  • A vulnerable third-party form, upload feature, or plugin that accepts files from the public.

Restoring a clean backup without closing the actual weakness leaves the same door open, and it is common for a site cleaned this way to be compromised again within days through the exact same route.

6. Bring the site back online and watch it

Once you are confident the cause has been identified and fixed, restore public access. Keep watching more closely than usual over the following days and weeks — check for the same signs covered in how to tell whether your website has been hacked, since a determined attacker sometimes returns through a different route if the first one is now closed.

What this does not cover

If personal data, passwords, or payment details may have been exposed, notification obligations to affected people and to relevant regulators are a legal matter specific to your location and circumstances, and this guide does not substitute for proper legal advice on that question. If the compromise involved encrypted files and a ransom demand, do not pay it — restoring from a clean backup achieves the same result without confirming the account is worth targeting again. Recovering from ransomware on a website covers that situation specifically. And if at any point you are not confident carrying out these steps yourself, contact support rather than guessing on a live, compromised site.

Frequently asked questions

Should I pay a ransom if one is being demanded?

No. Paying does not guarantee the attacker restores anything or does not simply demand more, and it confirms the account is worth targeting again. Restoring from a clean backup achieves the same outcome without funding the attacker.

Do I need to tell my visitors or customers?

If any personal data, passwords or payment details may have been exposed, you likely have a legal obligation to notify those affected and, depending on your location, a relevant regulator. This is a legal question specific to your circumstances and jurisdiction, so seek appropriate advice rather than deciding it alone under pressure.

Related reading