How to fix ‘The response is not a valid JSON response’.

What’s discussed here?

Upon updating some blog posts for this site, I was getting a big red banner on the post editor with the following:

error: the response is not a valid json response

Updating failed. The response is not a valid JSON response.

But it seemed that the post was still updating. Strange.

I have seen this before and found that a plugin conflict normally caused this issue.

After disabling a few plugins and trying again, the error was still persistent.

A couple of posts after researching on google suggested using the Classic Editor. No thanks, Im all-in 100% Gutenberg now and really loving it.

I have added a couple of solutions below:

Re-save your permalinks

My next step is to re-save permalinks.

After resaving, the issue appeared to have gone away for my use case.

Increasing fastcgi buffer size.

I noticed I was getting a 502 error in developer tools when viewing the console output. Looking at error logs, I then inspected the server error.log for that site. Then saw this log output:

2022/11/01 10:12:06 [error] 3550188#3550188: *5 upstream sent too big header while 
    reading response header from upstream, client: 123.123.123.123, server: 
    wpdocs.io, request: "POST /wp-json/wp/v2/posts/18880?_locale=user HTTP/2.0", 
    upstream: "fastcgi://unix:/run/php/php7.4-fpm-sdgsghtgrg.sock:", 
    host: "wpdocs.io", referrer: "https://wpdocs.io/wp-admin/post.php?post=185880
    &action=edit"

I noticed that disabling the LinkWhisper plugin made the issue go away, but the client still wanted to use LinkWhisper… so…

All the servers we use are NGINX/PHP-FPM.

Find the line in the nginx.conf file that says fastcgi_buffer_size

Changing the value from 16kb to 32kb fixed the issue for us.

fastcgi_buffer_size 32k;

Other Solutions

There are other solutions provided in this article on webspeedtools.com as well if resaving permalinks doesn’t work for you.

If the issue does come back, be sure that I will return and update this post with my findings.

Read more about the subject above