Error saving custom scripts in WordPress — How to fix
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 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.
Once you’re in ModSecurity, turn it off for your website. It is fairly instant.
Go back to your website. Close the notification saying you couldn’t save your custom script, and hit “Publish” again. Your site should publish.
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.
Wrong. I don’t have modsecurity enabled on my server and this is happening.
Ah man I’m sorry to hear it. This post helped a bunch of other people who wrote in to say so. If you figure it out please tell me so I can put your help up!
Thank you! This solution worked great!