An Unexpected HTTP Error occurred during the API request – Word press 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 to

wp-includes and edit http.php [ < wordpress 3.0 ] wp-includes and edit class-http.php [ wordpress 3.0 ]

Share on Facebook



Comments

  1. I get similar HTTP Error while uploading an image bro. Any solution for that ?

    – Robin

  2. Can u explain a bit about the error..or post a screen shot of the error

  3. 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 .

  4. This does not work in WP 3.0. There is no reference to the timeout in that file. Please advise.

  5. You can find it at wp-includes/class-http.php( line 220) @ word press 3.0.Hope it works 🙂

  6. 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

  7. 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

  8. 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

  9. @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

  10. 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?

  11. 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

  12. all is well says:

    thank you so much for providing error solution about 3.0,it really works

  13. 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.

  14. I can fix it but i need access to your site . Mail me at kan @ cre8tivenerd.com if you want me to fix it

  15. This setting is now in class-http.php and it’s not helping. Are there any other solutions?

  16. I dint find any alternate solution for this issue but will let you know as soon as i find one

  17. hello there,unluckily it’s still not working but thanx 4 this tutorial

  18. 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))) );

  19. 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…..

  20. Not working

  21. for wordpress 3.1.1 based on nginx+apache2 not working

  22. I Found Solution Change http.php on wordPress 3

    class-http.php

  23. 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…

  24. 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?

  25. Linards says:

    have the same problem, but i cannot even edit the class-http.php file.
    suggestions pls
    thanks

  26. 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.

  27. manusabu says:

    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 🙂

  28. I have the same error! but I need to help with version 3.2.1.

  29. I got the error An Unexpected HTTP Error occurred during the API request.

    i have edited those files still the problem is presets.

  30. 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.

  31. 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! 🙂

  32. 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))) );

  33. 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))) );

  34. I am not able to fix the error
    I think i need to change the hosting

  35. not working for me i tired this on my site http://www.taguer.com !! any other solution ?

  36. This work for me, thanks…..

    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))) );

  37. Sorry, correction…..
    Only works a few time, after that didn’t work again…..

  38. I’m using WP 3.3.2 and have tried the solution posted here. Doesn’t work for me 🙁 The error occured from nowhere. I did not install anything nor changed something on my WP install. Site was running ok until today. Please help.

  39. Hi Wpuser. I changed every file named above but no luck.
    The message “An Unexpected HTTP Error occurred during the API request.” keeps on appearing.

    I’m using WordPress 3.3.2.

    Please help..

  40. Hello there,

    Solution for the problem :
    “An Unexpected HTTP Error occurred during the API request”

    two solutions available :

    1) fix timeout value as mentioned above

    – if the problem still exist !! then the problem relates to the server which the website hosted on, to fix this problem go to step two

    2) contact your web hosting support & ask them to make sure that
    fsockopen
    isnt disabled in php.ini (through disable_functions)

    please all accept my best regards,,

Speak Your Mind

*