So you got that error when trying to add custom scripts to Wordpress:

Looks like something's gone wrong. Wait a couple seconds, and then try again.

Ignoring the grammatical error in that sentence (shouldn't it be "wait a couple OF seconds?"), let's get to solving the problem.

I get this every time I set up a new installation on a few different hosts and I try to add Google Analytics or Google Tag Manager scripts. I've got it in the standard WordPress themes as well as in Kadence themes.

Here's the error when it reared its ugly head again today:

The "Looks like something's gone wrong" error in Wordpress when you try to save a custom script.

The problem doesn't show up in your JavaScript console because the problem isn't even in the browser. The problem is in your web server — you're being blocked by a module called ModSecurity.

ModSecurity is an Apache module. But you can also find it on Litespeed servers like mine, which are very compatible with Apache.

The way to fix the "Looks like something's gone wrong" error in this case is to go into your server's CPanel and find ModSecurity and disable it temporarily. This is how I've had to do it every time.

In your CPanel console, ModSecurity has a green shield and it's under the Security section.

Modsecurity in the CPanel console

Once you're in ModSecurity, turn it off for your website. It is fairly instant.

Turning ModSecurity off to solve the "can't save custom scripts" problem
Turning ModSecurity off

Go back to your website. Close the notification saying you couldn't save your custom script, and hit "Publish" again. Your site should publish.

Publish your site again after fixing the ModSecurity problem

Remember once you're done to go back and turn ModSecurity back on! It's a security module that does something (and I haven't bothered to look up what).

I've never personally experienced this when using DigitalOcean servers — I've never had to disable the ModSecurity Apache module.