An Unexpected HTTP Error occurred during the API request – Word press error
18 Jun 2010 34 Comments
in Troubleshooting Tags: api, error, http, Wordpress, wordpress error
Did u come across the error ” An Unexpected HTTP Error occurred during the API request ” while installing a plugin or doing some task in word press admin dashboard like create a post, editing a post .I hope you fix it after reading this post.
Today when i tried to install a SYNTAX HIGHLIGHTER plugin using the default word press plugins search . I came across a 500 internal server error after hitting INSTALL button. I dint understand anything so i refreshed my page and hit INSTALL button again .This time it popped up a different error ” An Unexpected HTTP Error occurred during the API request ”
As usual google comes to the rescue . I found a solution for this problem at clickonf5 where he clearly explained why this error occurs and even posted a solution .
Reason
Word press sets a timeout limit for every request. If that limit crosses for certain request it pops up the error
Solution
In order to fix the error we need to increase the time out limit.Follow the below steps on how to increase time out limit
Step 1
Go to
wp-includes and edit http.php
Step 2
find
'timeout' => apply_filters( 'http_request_timeout', 5);
and replace it with
'timeout' => apply_filters( 'http_request_timeout', 30);
Step 3
Save Changes and install again
Hope you have fixed the error . Happy blogging
Last Update : July 06, 2010 10:50pm
Step 1
Go towp-includes and edit http.php [ < wordpress 3.0 ]
wp-includes and edit class-http.php [ wordpress 3.0 ]
Share on Facebook
34 Comments (+add yours?)
Leave a Reply









Jun 18, 2010 @ 13:51:26
I get similar HTTP Error while uploading an image bro. Any solution for that ?
- Robin
Jun 18, 2010 @ 14:03:16
Can u explain a bit about the error..or post a screen shot of the error
Jun 18, 2010 @ 14:04:32
Thats what I love about you Kan – you always make it everything seem so simple – while I just sit there and panic , pulling out my hair yelling ” Noooo not again ! ”
Great post , simple , direct and to the point without alot of jibberish !
Mia .
Jul 06, 2010 @ 16:44:08
This does not work in WP 3.0. There is no reference to the timeout in that file. Please advise.
Jul 06, 2010 @ 17:12:56
You can find it at wp-includes/class-http.php( line 220) @ word press 3.0.Hope it works
Jul 12, 2010 @ 09:19:03
Hi Kannan,
I have followed your instruction, and I’m still getting the same error when trying to search for new plugins from the WP Dashboard in WordPress 3.0
It also doesn’t seem to have made any difference to the length of time it waits before returning the error. Any ideas? Please?
Thanks in advance,
Marty
Jul 12, 2010 @ 10:29:43
Do you have sexy bookmarks plug in installed in your word press ? If yes try removing it and tell me if it works or not
Jul 13, 2010 @ 08:10:01
Wordpress 3.0 claims it “couldn’t connect to host” when you var_dump the request.
I found this line: wp-admin/includes/plugin-install.php (Line 44)
$request = wp_remote_post(‘http://api.wordpress.org/plugins/info/1.0/’, array( ‘timeout’ => 15, ‘body’ => array(‘action’ => $action, ‘request’ => serialize($args))) );
I did try changing the timeout here as well but it seems the api.wordpress.com/.. it is trying to load isn’t working correctly.
Don’t suppose anyone could shed some light on this?
Cheers
Aug 08, 2010 @ 19:33:30
@Stephen
I’m sorry that didn’t work for you, but thank you for pointing out that timeout setting because it fixed my problem when I changed it to 60 (instead of 15).
Thanks
Bradford
Sep 09, 2010 @ 16:19:31
This solution did not work for me. It’s strange – I have TWO blogs and they BOTH started doing it at the same time — and one of them does not have SexyBookmarks installed at all. I am guessing it is some server setting, but I am having trouble finding information on that. Do you know of anything on the server that would do that?
Sep 10, 2010 @ 03:12:43
No i don’t know but check this comment by sanjeev mishra http://www.clickonf5.org/wordpress/solved-an-unexpected-http-error-wordpress/5802/comment-page-1#comment-8347 .I hope it answers some of your questions and regarding the information on server settings i will try to find the information as soon as possible
Nov 19, 2010 @ 21:42:49
thank you so much for providing error solution about 3.0,it really works
Dec 26, 2010 @ 23:00:52
This fix didn’t work for me. I increased the timeout to 60, saved the changes and made sure the change took. Still, the error message “An Unexpected HTTP Error occured during the API request.” pops up very quickly.
This is a fresh install of Word Press too.. frustrating.
Dec 27, 2010 @ 01:38:59
I can fix it but i need access to your site . Mail me at kan @ cre8tivenerd.com if you want me to fix it
Jan 01, 2011 @ 15:09:42
This setting is now in class-http.php and it’s not helping. Are there any other solutions?
Jan 01, 2011 @ 16:06:05
I dint find any alternate solution for this issue but will let you know as soon as i find one
Jan 18, 2011 @ 16:41:51
hello there,unluckily it’s still not working but thanx 4 this tutorial
Mar 22, 2011 @ 05:21:34
Prior to WordPress 3.0
Edit file http.php in directory wp-includes and find the http timeout setting. It is by default set to 5. Increase to 30 or 60.
‘timeout’ => apply_filters( ‘http_request_timeout’, 60);
WordPress 3.0 and after
Edit file plugin-install.php in directory wp-admin/includes and find the timeout setting. It is by default set to 15. Increase to 60.
$request = wp_remote_post(‘http://api.wordpress.org/plugins/info/1.0/’, array( ‘timeout’ => 60, ‘body’ => array(‘action’ => $action, ‘request’ => serialize($args))) );
Mar 23, 2011 @ 09:44:31
The correct way to do this, as apposed to editing files.
Is just to add a filter:
add_filter(‘http_request_timeout’, ‘a_function’, 10, 1);
function a_function($current_timeout) {
return $desired_timeout;
}
Not sure if this will also adjust the plugin-install.php timeout but then I am adjusting the timeout for something more specific…..
Apr 07, 2011 @ 16:14:03
Not working
Apr 17, 2011 @ 09:40:39
for wordpress 3.1.1 based on nginx+apache2 not working
May 18, 2011 @ 18:41:35
I Found Solution Change http.php on wordPress 3
class-http.php
May 24, 2011 @ 12:45:57
My Http.Php doesn’t even have time out settings in it, searched for ever single variation on it, counted to the right line, EVERYTHING and it isn’t there.
As always with wordpress I end having to do it with http://FTP... yay for progress…
Jun 22, 2011 @ 09:45:02
no luck for me.i did everything but same error.i am using latest version of wp but no luck for me.can anyone help me please?
Jun 26, 2011 @ 13:04:19
have the same problem, but i cannot even edit the class-http.php file.
suggestions pls
thanks
Jul 13, 2011 @ 08:30:36
for new wordpress you should edit class-http.php not http.php. You can raise the timeout from 5 to 30/45. or 0 which means no timeout limits. if this solution is not works please upload the plugins manually.
Aug 01, 2011 @ 06:19:35
Hi Topher,
Many thanks for your guiding, i try a lot of things but it does not work.
Your guide lead to me a exact solution.Thanks once again
Aug 13, 2011 @ 18:43:52
I have the same error! but I need to help with version 3.2.1.
Oct 13, 2011 @ 10:48:30
I got the error An Unexpected HTTP Error occurred during the API request.
i have edited those files still the problem is presets.
Oct 13, 2011 @ 12:02:20
I’m using WordPress 3.2.1.
I have changed timeout limit in class-http.php file in ‘wp-includes’ folder of WordPress installation, but no results. I recieve the same error message:
“An Unexpected HTTP Error occurred during the API request. Try again”
Please help me to resolve this error.
Oct 13, 2011 @ 23:18:46
I received this error after installing WP for the first time while trying to search for templates! Returned first search result and then when I tried again – nothing but this error. Doesn’t matter what I search for… have no idea why this would happen when I haven’t even created anything yet! Clearly, I’m in over my head!
Oct 14, 2011 @ 00:54:43
follow this link to learn how to fixed this error
http://www.cornerofart.com/2011/10/14/wordpress-an-unexpected-http-error-occurred-during-the-api-request/
Dec 21, 2011 @ 12:05:13
I tried but it did not work. I search and found the solution for WordPress 3.3
Edit file plugin-install.php in directory wp-admin/includes and find the timeout setting. It is by default set to 15. Increase to 60.
$request = wp_remote_post(‘http://api.wordpress.org/plugins/info/1.0/’, array( ‘timeout’ => 60, ‘body’ => array(‘action’ => $action, ‘request’ => serialize($args))) );
Dec 21, 2011 @ 12:42:22
This is the only correct fix for 3.0+ Wp versions as posted by Topher
Prior to WordPress 3.0
Edit file http.php in directory wp-includes and find the http timeout setting. It is by default set to 5. Increase to 30 or 60.
‘timeout’ => apply_filters( ‘http_request_timeout’, 60);
WordPress 3.0 and after
Edit file plugin-install.php in directory wp-admin/includes and find the timeout setting. It is by default set to 15. Increase to 60.
$request = wp_remote_post(‘http://api.wordpress.org/plugins/info/1.0/’, array( ‘timeout’ => 60, ‘body’ => array(‘action’ => $action, ‘request’ => serialize($args))) );