Related
Today I got an issue in WordPress. When I try to create a new page and uploading a new image in the WordPress admin section, I try to find out the solution, but I didn't get it... So after sanding an hour I got a solution...
Error
"Publishing failed. Error message: The response is not a valid JSON response."
Go to settings>permalinks. Select "Post name" and save.
Try updating your posts/pages. If it doesnot work, try selecting another option in the settings>permalinks.
Right now, you can use the Classic Editor plugin for fixing this issue.
The answer for the error is the editor I didn't know, but there is a new editor issue. If you are getting the same issue, then please use the below plugin. For fixing these issues, I'm doing R&D on this issue. If I get an exit solution, then will I make an update soon...
I had the same problem on a local dev environment and found the issue was due to rewrite permissions. Make sure your .htaccess file has the proper permission.
sudo chmod 755 .htaccess
After permissions are set, save your permalink settings. If the problem still exists, make sure mod_rewrite is enabled. The following will work for apache2 on Ubuntu.
sudo a2enmod rewrite
sudo systemctl apache2 restart
If still not working, your apache config is probably too strict. The following should do the trick for apache2 on Ubuntu. Edit /etc/apache2/apache2.conf and look for the root directory block. It's normally the one with /var/www like below. You will probably see AllowOverride None. Just change it to All like below for your local, but you probably want to do some research and be more secure on a production server.
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
After the change is made do another restart on apache and all should be good.
sudo systemctl apache2 restart
Changing the permalink settings as mentioned previously fixed the problem for me. If you keep "Post name" as the permalink setting, then the .htaccess file needs to be writable by wordpress.
Alternatively the below can be pasted at the bottom of .htaccess file. Mod_rewrite changes are executed from the bottom of the file first.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Maybe you have a security issue with mixed content (HTTP and https URLs).
Step-1
1. 1. Check your Wordpress URL. Go to Settings -> permalink then click plain and save a page. then remove error
Step-2
Check your Wordpress URL. Go to Settings -> General
Change Wordpress Adress and Site Adress to https://
This solved the problem for me
Navigate to Settings > Permalinks. Select the permalink structure to Post name and save. Now try saving your post/page.
Here I have shared the screen-shot for your reference.
The problem should have been resolved.
Once your issue is resolved then you can select an old option in Permalinks if you want.
Note: If you have already selected Post Name then you need to select other option for reset permalink.
Go to /etc/nginx/sites-available/
open default file --> sudo vi default or sudo nano default
Add Below line to the location:
Add the comment :
#try_files $uri $uri/ =404;
Add this line : try_files $uri $uri/ /index.php?$args;
See the screenshot below described with red line :
I just installed classic editor plugin and it sorted out the “The response is not a valid JSON response” problem.
I had the same "not a valid JSON response" error when trying to publish my content. WordPress seems to do a JSON post when publishing a new post/page so I checked the network tab in my Developer Tools. If you check the "response" tab for this JSON call you might see some more details about this invalid JSON response.
In my case (yours might be different) some deprecated debug message was outputted before the actual JSON data and messed up the response. After fixing the deprecated message publishing worked again.
<br />
<b>Deprecated</b>: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in <b>Unknown</b> on line <b>0</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent in <b>Unknown</b> on line <b>0</b><br />
{__NORMAL_JSON_DATA_HERE__}
Now, here there are two server blocks, first one is running on port 80.
for second server block there is a port 443 where you should implement the below code.
server{
#ssl configuration
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404; // comment this block
try_files $uri $uri/ /index.php$is_args$args;
}
}
Now exit and restart nginx server.
~$ sudo service nginx restart
you are done. enjoy.
In My case, it was a Firewall issue. A ModSecurity firewall rule was triggered for the website. I contacted the hosting provider (NameCheap), they identified the issue and then whitelisted the triggered rule on the server. Then the problem was resolved.
Looks like this still has not been fixed.
A workaround that worked for me (posting in case it works for someone else too) - in my case I was using an HTML block which was causing the issue. What I did was to add a Paragraph block > Edit as HTML. It resolved the issue for now. It's a shame that WP didn't look into it yet, seems like it's been happening for a while.
I had this same error and the cause in my case was a shortcode used in the page and the function that defined the shortcode was using 'echo' to output the data rather than using 'return'
I'd been getting the same error message when adding and/or updating pages, in addition to various other random errors. I was getting the errors on both my local development server and my webhost. When changing to one of the default themes (e.g. twenty nineteen), the errors would go away. For me, the problem turned out to be in my page template files. I'd noticed that when choosing a template for a newly created page, I'd have multiple choices with the same name.
I have several page template files (e.g. about-page.php, contact-page.php, services-page.php, etc.). When creating these files, since most of these pages were similar, I would just copy/paste from an existing file to make a new xxxx-page.php file. However, in some of those copied files (not all), I'd forgotten to modify the 'Template Name' (at the top of the file).
After I'd gone through and made sure all of my template files had unique names, the JSON error went away. All of my other errors disappeared as well. I'm using Wordpress 5.4.
My issue was .htaccess related. I got the hint from LucasBr's comment about a ".htaccess configuration problem". Since I had copied the site to my local dev environment. I needed to update the custom mod_rewrite settings to match my setup.
The important lines were:
RewriteBase /
and
RewriteRule . /index.php [L]
They had previously been set to access a sub-directory site.
I have some echo in some of my custom plugins, so this was also causing this issue.
I had the persisting issues. Before I could find the solution, I replaced PHP 8, as this was custom PHP Installation.
But nothing worked.
The solution was found during Drupal Installation.
Enable Opcache(only for Drupal though)
Allow Mod rewrite, Allow all(in my httpd.ini file there were three occurrences of Mod Rewrite,
And they were changed to None to All again none all this was small letter, and final one None to All
Restart httpd with httpd -k restart (CMD as Administrator)
This resolved.
I encountered the same kind of problem for a different reason with one of my client and never saw it as a potential solution.
If you enabled a W.A.F (like cloudflare or similar), one of the side effects can be this error, so be sure to disable to disable you waf if none of the other solutions are working.
If you use mod security 3 with Wordpress, you might get this message:
Publishing failed. The response is not a valid JSON response.
To remove it, you would need to add this rule to your exclusions file called
REQUEST-900-EXCLUSION-RULES-BEFORE-CRS
as follows:
# Remove Publishing failed. The response is not a valid JSON response.
SecRule REQUEST_HEADERS:Host "example.com" \
"id:1025,\
phase:2,\
pass,\
nolog,\
chain"
SecRule REQUEST_URI "#beginsWith /wp-json/wp/v2" \
" ctl:ruleRemoveById=933210,ctl:ruleRemoveById=949110"
You might need to change the rule id and change example.com to your domain name. After that, do this:
sudo nginx -t
if no problems were detected, restart nginx:
sudo service nginx restart
sudo systemctl restart nginx
This is a permalinks error.
Do these steps to fix it (depending upon the cause in your scenario) as explained here: https://wordpress786.com/updating-failed-error-message-the-response-is-not-a-valid-json-response/ :
go to settings > permalinks and save them once again
if you're on nginx, go to site nginx conf file and make sure that it contains the rules for wordpress permalinks (usual nginx configurationn for wordpress, ask me if confused)
restart nginx if you make any edits to conf file
If you face issue on image upload follow this: https://navinrao.com/the-response-is-not-a-valid-json-response/
I was getting this issue while updating normal text too.
The issue I face was due to having javascript:void(0) keyword inside my link () .
Please be sure if your content has keyword containing javascript
before updating.
<i class="fa fa-linkedin" aria-hidden="true"></i>
After I remove javascript:void(0) ; it works fine.
Have a nice time :)
Try removing any redirects to the WordPress site including subdomains.
The question was edited 3 times and it now includes VPS and Centos tags, because i think there is something wrong with my VPS config file.
Ok, first, I've looked through all the questions asked here, and there is no answer to the issue I have.
The problem is that when I try to copy/paste and update or create WP post, I get this warning that says: "You don't have permission to access /wp-admin/post.php on this server."
The strangest thing is that when I copy/paste it mostly crashes only if there are some special format like Italic or any symbol, but not every like (). So if I paste text, it mostly crashes but not always.
Now, to make the things even stranger, I had a post that was doing just fine, I mean it used to appear fine on the blog. Then I've tried to create a contact page, I've published it and it didn't show on the blog. There was a message saying nothing found there on the link. Then I've started to click around and I've noticed my post that was doing right disappeared too. I mean it's still there, but when you click on read more it says nothing found.
I've turned off all the plugins I'm using (in fact only Fourteen Color) and have changed the theme, but with no result at all.
Any idea why does this happen?
I'm hosting it on a virtual server and there are running 2 sites more at the same Ip, but I don't think, this could be the problem.
Previously I was playing with SSL and I thought that might be the problem, but then I deleted the domain and have created anything from scratch and the issue persists.
Pd. When I try to publish a raw entered text from the keyboard I've no problems, but when I paste it, it usually crashes the post.
Edit: My .htaccess file is here:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Edit 2: It seems I can't post links too. When I try to post a link I get the same error.
Edit 3: I'm trying to locate the php log file, but it seems there's nothing there. So my thought is: what if the error have to do with wp trying to write the log but it can't get permission? I have the php logs enabled in the config so there should be at least one, but i can't find any. Does anyone can tell me, where I have to look for the logs. Now I'm looking on /var/log but there are no php log file.
Ok, I have to edit the answer, because despite everything worked fine, the problem appeared again. So, this time I dug deeper only to find out, that the problem were laying in my mod secure conf, so I had to set SecRuleEngine from On to DetectionOnly, and now the issue is gone.
Previously it was detecting every attempt to update the post like an XSS attack.
I had an issue like yours a few years ago and it drove me crazy, but I had to try out some solutions to finally find out the perfect one for me. Try one of these, they can't do no harm:
First: try to CHMOD your post.php to 774. Or even better, for the sake of your solution, chmod your wp-admin and wp-content folder to 777 and see if it works and then switch it back, so you will be able to pin point it.
Second: Add this part to the beggining of your .htaccess file:
<Files post.php>
Order Deny,Allow
Deny from all
Allow from all
</Files>
Instead of "all" in the "Allow from all" field you can just enter your IP.
Third: In my case, renaming this part
<IfModule mod_rewrite.c>
to this
<IfModule mod_rewrite.so>
helped, as I think this is a platform-specific, or configuration-specific issue, where Mac OS and Linux Apache installations are set up for .so AKA 'shared-object' modules. Looking for a .c module shouldn't break the conditional, I think that's a bug, but it's the issue.
Try any of these and I hope something will help you as it did to me.
My website is ready to be deployed and I am trying to set it up online.
Some informations:
The host is OVH.
It doesn't allow SSH, I have to send my files with FTP. No command line either.
I want to be able to set up the website in a subdirectory: /www/test for now (my current website is still in /www).
The problem:
When I open the URL my-website.com/test, a Symfony exception tells me No route found for "GET /test/", which clearly means that Symfony doesn't know it is in a sub-directory.
How can I tell it?
EDIT:
I just realized it worked when I access my-website.com/test/web.
Here I wrote exactly about that: https://www.refactory-project.com/install-symfony-app-in-a-subfolder-of-an-existing-site/
Upload the application part
Start by uploading the application folders at the same level of your site root:
[ftproot]
-- public_html
---- ...
---- ...
-- symfonyapp
---- app
---- bin
---- src
---- vendor
---- web
------ app.php
------ app_dev.php
------ ...
---- composer.json
---- composer.lock
Move the web part
Move the content of the "web" folder into the desired subfolder, i.e. "myapp".
[ftproot]
-- public_html
---- ...
---- ...
---- myapp
------ app.php
------ app_dev.php
------ ...
-- symfonyapp
---- app
---- bin
---- src
---- vendor
---- composer.json
---- composer.lock
Let the web know where is the application
Edit files app.php and app_dev.php and insert the new application location.
require_once __DIR__ . '/../../symfonyapp/app/bootstrap.php.cache';
require_once __DIR__ . '/../../symfonyapp/app/AppKernel.php';
Let the application know how the web folder is called
Edit file composer.json with the new web folder name
{
...
"extra": {
...
"symfony-web-dir": "../public_html/myapp"
}
}
You're sort of setting yourself up for hardship if you are deploying a Symfony app to a host that does not allow SSH - for instance if you want to rebuild your cache you will have to manually nuke your app/cache/* dirs?
To answer your question directly, if your Symfony project is in /www/test/ then Symfony's web directory is /www/test/web so you need to use a url like:
http://foo.com/test/web
For completeness, try accessing the explicit url - /test/app.php and /test/app_dev.php respectively. If you receive a Symfony error page in either case you know you are on the right path at least.
Edit #1
Something to point out: your project and configuration files and may be readable with this deployment scenario - which is not ideal - so you might want to check this and take some actions to secure this directory if possible. I appreciate that this is probably a test deployment so it might not be a big deal, but it's always good to keep mindful of security :)
Edit #2
Okay YMMV with this, I am no .htaccess expert but you could deploy your symfony app to /www/symfony/ and rewrite the /test URI to show /symfony/web/ instead; e.g:
RewriteEngine On
# rewrite all `/test/*` uris to `symfony/web`
RewriteRule ^test(.*)$ symfony/web/$1 [L,QSA]
# direct access to /symfony dir is a 404
RewriteRule !^symfony/web/$1 - [R=404]
This should serve all applicable uri requests (to /test and /symfony/web itself) to Symfony, while restricting direct access to the symfony core files.
Haven't tested this, so how this will play with Symfony's own .htaccess is not something I can answer off the top of my head.
How about using .htaccessfile to achieve your goal. As far as I understand your problem your symfony app works IF you access it via web folder for example foo.com/test/web
try using the following code in your .htaccess file which will sit at the root of your test directory
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) /web/$1 [L]
</IfModule>
please replace the domain.com with your domain name.
I am having an issue in WordPress admin, where the images are not cropping in WP "edit image" for a site I am creating and I do not know what the cause is.
I've read a few similar topics, but nothing seems to make a dent. I've deactivated all plugins and checked the server, but things seem to be set up just fine.
Can someone possibly steer me in the right direction on how I can get it to work or what might be causing the issue?
Keep in mind, the interface is not intuitive and it's easy to forget that the [Save] button is still deactivated if you do the following:
Click the crop button.
Select the area you want.
You must do the opposite.
Select the area you want.
Click the crop button.
I had the same issue but the problem was missing the GD library, https://www.digitalocean.com/community/questions/installing-the-gd-image-library
To install (Linux/ Apache2):
sudo apt-get update
sudo apt-get install php5-gd
sudo service apache2 restart
I faced the same problem and got it solved. This may be a very late response, but can be useful for other people facing this problem.
This is how I resolved it:
Check your functions.php file. See, if you have the closing tag at the every end of the file.
?>
removing this tag fixed my problem. Also can check out this link. Hope this helps!
This should solve your problem:
Remove all blank lines and whitespaces in /wp-content/themes/name/functions.php + the including files.
Remove all blank lines and whitespaces in /wp-config.php file
Check that php5-gd is installed.
Permissions changed to 777 for testing /wp-content/upload/ + sub folders
Remove closing ( ?> ) php tags in /wp-content/themes/name/functions.php + the including files.
Turn off all plugins.
Rename your theme and change to default theme.
None of the above worked for me. So in an effort to give back after taking so much from stackoverflow, here is what I did:
Sometime during the install process a URL rewrite rule was created in IIS. I disabled this rule and then the image crop worked!
You may be missing the GD library.
To check that the server has it installed, try php -me at the command line. Scan for gd module.
If it's missing, get it: sudo apt-get install php7.0-gd
I found that in my OVH WordPress server, version 4.7.5, imagemagick was not installed and is required for this function to work properly:
sudo apt-get install imagemagick
sudo service apache2 restart
If someone is trying to accomplish this in an AWS Linux Environment, these commands worked for me:
yum install php71-pecl-imagick.x86_64
Of course, you can search for the corresponding imagemagick package for your environment:
yum search imagemagick
later, don't forget to do a:
service httpd restart
for the changes to take effect on your WP
After ruling out several causes
( PHP modules, memory limits ), trying to get useful debugging info, and migrating the site to different hosting, I found that the problem was caused by rewrite rules in the .htaccess file.
In this case the rules where added by the security plugin All In One WP Security. Maybe, a newer version of the plugin would have fixed it, but I replaced it with another security plugin some time ago.
With removing all rules from the .htaccess and gradually reintroducing them I
discovered that the specific block of lines in .htaccess causing the problem was:
# 5G:[QUERY STRINGS]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (\"|%22).*(<|>|%3) [NC,OR]
RewriteCond %{QUERY_STRING} (javascript:).*(\;) [NC,OR]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3) [NC,OR]
RewriteCond %{QUERY_STRING} (\\|\.\./|`|='$|=%27$) [NC,OR]
RewriteCond %{QUERY_STRING} (\;|'|\"|%22).* (union|select|insert|drop|update|md5|benchmark|or|and|if) [NC,OR]
RewriteCond %{QUERY_STRING} (base64_encode|localhost|mosconfig) [NC,OR]
RewriteCond %{QUERY_STRING} (boot\.ini|echo.*kae|etc/passwd) [NC,OR]
RewriteCond %{QUERY_STRING} (GLOBALS|REQUEST)(=|\[|%) [NC]
RewriteRule .* - [F]
</IfModule>
I was not able to crop images, too. The area, where the cropping should show was just blank, instead I got the error message:
Image crop area preview. Requires mouse interaction.
Now, there was also other suspicous things: the media image library showed no thumbnails. When activating developer mode in the browser, I noticed some resources of Wordpress could not load.
Solution: the access rights to /wp-content were broken, Apache was no longer able to read the files. In my case, recursively changing the access rights of wp-content folder to rwxr-x--- did solve it.
If your WordPress installation hosted on Amazon Red hat, please, do the following:
sudo yum install php-gd
For more check here.
I tried everything here, but nothing helped. Eventually, I found an article which mentioned giving IIS_IUSRS permissions to the WP folder. And that finally got the crop tool working.
I re-saved the functions.php file with file encoding UTF-8. It worked for me.( Windows 10 )
If you've tried just about everything but none of the suggestions work, read on.
I was experiencing this issue on just one site in my dev environment where all other sites were working fine. It ended up being a single included file with UTF-8 BOM header. Removed it and voila!
I was having this issue because the Media Previewer/Cropper was attempting to pull the images from http instead of https and my server kept reporting an error 400 when attempting to pull the source images because I do not currently expose traditional non-ssl HTTP.
IE: I'm running on an alternate port and using https://server:9090. When I attempt to crop an image, it tries to load the image via non-ssl http://server:9090/path/to/image.png. It doesn't use the correct protocol and the server responds with a 400 error, thus the cropper is unable to load the image and continue.
In my case, this was happening in the "Customize" section under "Themes". When using the Media Library, it loaded the image correctly over SSL. However, I can't change the image in the customizer without enabling http.
I had the same problem, but for me the solution was quite easy. All I had to do was to remove the image from the media page and then upload it again.
Hope this helps someone else
My problem was because I was uploading an SVG, so it could not crop it :D.
It worked after I saved it as an .png
I've recently installed Wordpress and can't seem to get the website to display friendly URLs no matter what settings I use inside the Dashboard or in an .htaccess file. I've tried numerous versions of Wordpress and still can't achieve what I need, despite succeeding on hosts other than Concentric/XO, any idea why?
Update: I released a plugin that does all of this for you. However, you still need to follow the steps for the .htaccess file. Have a look here: http://wordpress.org/extend/plugins/permalink-fix-disable-canonical-redirects-pack/
Follow these steps before you attempt to install WordPress for the first time. If you have already installed it, start over.
To get Permalinks working you need to create a .htaccess file, WordPress can't do this automatically on this host. Here is what the basic .htaccess file should look like:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Make sure you create this file using an editor that allows for unix formatting (like PSPad, or VIM, Textmate, etc.), using notepad will give you a parsing error - it has something to do with invisible end of file characters(CLRF). Make sure the last rule has a hard return after it, it's required. .htaccess files are cached for up to 15 minutes so you may have to wait for it to kick in.
Next you'll need to edit your wp-settings.php file so open that up in your editor. Add the following code right above the closing ?> php tag:
if(isset($_REQUEST['q'])) {
$_SERVER['REQUEST_URI'] = "/" . $_REQUEST["q"];
}else{
if (empty($_SERVER['QUERY_STRING'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
} else {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . "?" .
$_SERVER['QUERY_STRING'];
}
}
If someone can write that block of code more cleanly feel free, I'm not an expert PHP programmer.
Once that block of code is in place you can proceed to run the install.
Now that WordPress is installed you'll have to do one more thing before you can start blogging:
Create a new file called: disable-canonical-redirects.php and upload it to the wp-content/plugins directory.
Drop this block of code into that file:
<?php
/*
Plugin Name: Disable Canonical URL Redirection
Description: Disables the "Canonical URL Redirect" features of WordPress 2.3 and above.
Version: 1.0
Author: Mark Jaquith
Author URI: http://markjaquith.com/
*/
remove_filter('template_redirect', 'redirect_canonical');
?>
Now you need to enable that plugin, go to the Admin login page:
example.com/wp-login
Enable the plugin you created. That's it, you're on a horse.
Ask them whether they have mod_rewrite enabled.
To find out yourself, try adding a .htaccess file containing gibberish first:
sadölkasdfksdakföasldfg
if putting that onto the webspace, and then trying to access any page on it results in a 500 error, htaccess files get parsed.
Then try adding a "real" .htaccess file:
RewriteEngine On
if that works without a 500, then URL rewriting should be turned on.