Raids are a mechanic added alongside the Minecraft Village & Pillage Update. During this event, multiple waves of Pillagers will attack a Village you visit, provided you have the Bad Omen Effect.
Sadly, Raids are pretty tricky, as mobs such as Pillagers, Vindicators, Ravagers, and Evokers will group up and attack a Village in unison. Without good defenses, you’ll probably lose quite a few Villagers who might be at a high level.
With that said, you might be searching for a way to end Raids. Luckily there are a few methods for disabling Raids before they’ve happened or even canceling them as they happen.
Stopping a Raid Before it Starts
Raids are only triggered if you enter a Village with the ‘Bad Omen’ effect active. With Vanilla Minecraft, the only way to obtain Bad Omen is by killing an Illager Captain, the Pillager equipped with a Banner.

You can check your inventory at any time to see if Bad Omen is active, as it will be shown on the right-hand side. So if a Raid hasn’t started yet, make sure to remove Bad Omen, which can quickly be done by drinking a Bucket of Milk.
Otherwise, you can wait it out. Expect Bad Omen to last around 2 hours on the character, which is quite a long time. The level of the Bad Omen Effect will determine the difficulty of a Raid, including whether the spawning Pillagers have enchanted equipment.

Contrary to popular belief, a Wolf can not carry the Bad Omen effect. However, if you have a tamed Wolf and it kills an Illager Captain, then Bad Omen will automatically be applied to you.
Break Villager Beds
One of the easiest ways to get rid of a Raid that’s already in progress is to destroy every Bed inside a Village. If that doesn’t work, destroy any job site blocks so that Villagers are stripped of their professions.
What this does is stops a Village from becoming a Village. Instead, it’s the same as any other structure in the game world. Pillagers will become confused, and the Raid will end instantly.

Any Pillagers who remain will still be in the area and can be killed. No new waves of a Raid will start. It’s a good idea to trap your Villages inside while doing this to keep them safe, as they can still be targeted.
Wait it Out
By default, a Raid lasts for 48,000 ticks in Minecraft. This equates to around 40 minutes in real-time. So take a break from your Village and come back later, as the Raid will become ‘Expired.’
Even though the Raid has ended, again, any remaining Pillagers will remain and will have to be defeated. No new waves will take place, and you can resume as normal.
Delete a Raid
If you’re playing Minecraft Java Edition, a Raid can be canceled by deleting a file from your world save files. Head to your Minecraft folder; the quickest way would be to go to Options > Resource Packs > Open Pack Folder when Minecraft is already open.
Then go up a level to the main directory, and open the ‘data’ folder. Inside is a file called raids.dat, which you should delete when your world isn’t loaded. Doing so will cancel the raid event and leave any remaining Pillagers behind.
You should back up your world before using this method. There might be a warning when loading up the world after deleting the raids.dat file, but it can be safely ignored.
Switch to Peaceful Mode
During a Raid, players can quickly switch to Peaceful mode, removing all hostile mobs and ending any in-progress Raids. This is probably the easiest and safest method, but it involves enabling cheats.

If cheats aren’t enabled in your world, go to the menu, and choose ‘Open to LAN.’ Ensure ‘Allow Cheats’ is set to ON and press the ‘Start LAN World’ button. Now when you go into the game’s options, the difficulty option will be available and can be switched to Peaceful.
Preventing Future Raids
You can take a few steps to prevent Raids in the future. Firstly, always be aware of whether you’re carrying the Bad Omen Effect when entering a Village. If you are, drink a Bucket of Milk, which removes all effects.
Raids can be brutal, and it’s possible to disable them entirely using commands. All you have to do is enter the following command into the chat: /gamerule disableRaids true
Cheats will be enabled for this command to work. You can take a look at the steps above under ‘Switch to Peaceful Mode’ to find out how to enable cheats in a single-player world. For servers, you’ll need operator permissions.