Home > WordPress > 20th November 2009

SOLVED – An Unexpected HTTP Error occurred during the API request on WordPress Backend

Sometimes you will see an error message as ‘An Unexpected HTTP Error occurred during the API request’ after requesting a page on WordPress Admin Dashboard. It may happen for 2 -3 minutes and then after that the panel starts behaving in a normal way. If you are getting this error frequently on your dashboard, then here is a fix / solution for this error.

WordPress sets a timeout limit for every request. If that limit crosses for certain request, in that case you will get this message. If you need to resolve this issue, you can do that by increasing the time limit to a higher value. To increase the timeout limit of requests, go to the ‘wp-includes’ folder of your wordpress installation and edit http.php file over there. Here is the screenshot of the piece of code where you need to make the changes.

http_request_timeout

We have attached below the before and after changes in http.php file to avoid this error message.

Before Change

 'timeout' => apply_filters( 'http_request_timeout', 5),

After Changes

'timeout' => apply_filters( 'http_request_timeout', 30),

Since we have increased the time limit from 5 seconds to 30 seconds, now you will not get this error message in your admin panel. You may increase this timeout value with any amount as per your choice. As I told you that this error message is appearing because the page request is crossing the time limit. It may happens because of plugins used in your WordPress. If you are using lot many plugins which are not properly optimized, you may get this error. Go thru the wordpress optimization technique post to optimize your wordpress set to make your wordpress setup a bit lighter.

Update: In newer versions of WordPress, you will find the above code in class-http.php file in ‘wp-includes‘ folder of your WordPress installation.

 

41 Responses to “SOLVED – An Unexpected HTTP Error occurred during the API request on WordPress Backend”
  1. George Serradinho says:

    I actually got this message yesterday and I had no clue what was going on. Thanks for sharing this, helps me out a lot.

  2. Ruchi says:

    Thanks a lot for solving this problem, i will give it a try, i am facing this from past 7 days, i thought this must be because of the plugins which i have installed recently, even update on newer version of plugins is failing at times, is this the reason for it ? Can you throw some light on it ?

  3. izzat aziz says:

    i often get the error.. thank for the tips it really helpful.. because i hate to refresh over and over..

  4. Ramkumar says:

    I havnt faced this problem yet, but will be very helpful if it happens in future.

  5. Sanjeev Mishra says:

    If you are using any Plugins which is not properly optimized, in that case you may face this issue. You may also face this problem when your blog is getting nice amount of traffic but still you are on shared hosting with bandwidth restrictions. WordPress is very much bulky and that’s where Super cache plays an important role. But in case of admin panel, it doesn’t cache anything. In that case, every time your WordPress setup executes too many PHP/Database code. That’s why we face this issue in backened only.

  6. Sanjeev Mishra says:

    I am glad that the solution helped you. Thanks

  7. BlogrPro says:

    So far I didn’t face this problem. But will try this to avoid in future.

  8. S.Pradeep Kumar says:

    Cool buddy.. I got this error last week.. when trying to edit and open my posts… thanks a lot.. :)

  9. greg says:

    Thanks for a great tip – I too get this problem frequently!

  10. Josh says:

    Hi Sanjeev,

    First let me say THANK YOU for giving an understandable reason as to why this happens… I mean, I already knew, but it seems as though everyone else who has offered up this solution just says “do this, and it works” rather than explaining as you did in this comment I’m replying to.

    Maybe you wouldn’t care to drop your opinion over at the WordPress.org forums?

    It seems that everyone is extremely quick to point the finger of blame at SexyBookmarks as the culprit, when that is NOT the case at all… There are tons of people who’ve had this same issue with a clean WP install…

    Anyway, thanks again for giving people a clear and resolute explanation.

  11. Josh says:

    Sorry, forgot to leave the direct link for you: http://wordpress.org/support/topic/227430

  12. Sanjeev Mishra says:

    Thanks a lot Josh for the compliments. I am a big fan of Sexybookmarks and I personally feel that Sexybookmarks is not a culprit for this issue.

    I have shared the info and solution on WordPress.org forum (link provided by you). I hope people will start making the suggested changes and enjoy WP without this issue.

  13. Jason says:

    Issue is – I can’t find wp-includes/http.php in my file manager directory at godaddy.com. I have the latest wordpress installed. Help?

  14. Sunny Khiani says:

    SOLVED

    1) Look for “feedity_widget_feed = “http://feedity.com/rss.aspx/sexybookmarks-net/UldQVFNb” in your plugins folder/sexybookmarks/sexy-bookmarks.php

    2) Uncomment it or add a FEED that is active such as below:

    // Your Feedity RSS feed URL
    //feedity_widget_feed = “http://feedity.com/rss.aspx/sexybookmarks-net/UldQVFNb”;

    3) Apply ‘timeout’ => apply_filters( ‘http_request_timeout’, 30), to your http.php in wp-includes

  15. Andrea says:

    Thanks a lot! I was having this issue over and over. I made a reference to this post in my blog in Spanish: http://bit.ly/cdoqZQ

  16. Ejaz says:

    Hi Sanjeev,
    First thanks for an Excellent plugin, but even after changing timeout to 30 the problem was not solved.

    I was never able to used Smooth Slider Options page due to this error (although I have made changes via database).
    This error come soon after clicking Settings > Smooth Slider. It takes about 2-3 sec after click so it does not seem timeout issue. Rather an issue with communication with API.

    Thank You

  17. simrandeep singh says:

    i get a problem but its not solved…if i try to search any themes then this error occurred….i tried ur solution but its not working….
    plzz provide me working solution as soon as possible…..

  18. zoul says:

    Thanks.. you’re really help me a lot in this matter..

    Thanks again

  19. Marcin says:

    Wow! thank you. It helped in my situation.
    Now the last thing I need to find a solution for is how to implement Google Custom Search Plugin for WordPress, I have been following directions from blog.nedsferatu.com/adding-google-adsense-custom-search-to-wordpress,but it seems I can’t figure out what went wrong, as I can’t see search results of my search, and the website is just refreshing.

  20. Mandy says:

    Hello, actually i get this error when i want to change setting on Cute profile you developed. i try your solution but, i have to say, the code you mention in my http.php file does not exist! so i am unable to change the time limit, and the plugin is still not working. Please help me out, I want to use this excellent plugin!!!

  21. Claudia says:

    Thanks, good to know that this is a time-out error. I was wondering what was suddenly wrong with my blog, but I think I have quite a slow internet connection today. I will try again tomorrow and when still having that problem I will try to set the timeout to 30. Thanks again!

  22. Ejaz says:

    Hi Sanjeev,
    I have noted that smooth slider admin interface works perfectly on our live server but gives HTTP Error on local development machine (which is behind proxy). I have changed timeout but could not get any better result.

    I think your script is giving error because it could not connect directly to internet to get live data (links etc.). Is there any solution for such case?
    Thanks in Advance

  23. Ali Qayyum says:

    first i really thankful to you for solving my issue.
    now another issue is, when i submitted the comment on any post
    it given me an error
    nothing found for comment

    please help me
    thanks

  24. rie says:

    Hi, Sanjeev.

    I got this error while trying to add new plugin for my blog. This info helps me to solve it. Thank you:-)

  25. Burns says:

    Thanks a lot. is solved my problem

  26. Ozell Claiborne says:

    Useful post. Lucky me I discovered your web-site by indicent, I bookmarked it so I can locate it next time.

  27. Sparklyscotty says:

    Thanks! :D

  28. RicardoRmz says:

    On WordPress 3.0 this function is declared on wp-includes/class-http.php (line 220)

  29. Gabi says:

    Thanks both to you and RicardoRmz!

  30. digitalwarez says:

    thanx a lot………worked grt

  31. Rahinur Rahaman says:

    I’m using WordPress 3.0 and your solution is not working for me. Basically there is no function request in http.php file. Could you please give a solution for 3.0.

    Thanks in advance.

  32. dJumTKS Weblog says:

    hello sanjeev, thank you for your post, it solved my problem :-)

  33. Andhi Irawan says:

    dear Sanjeev, thanks for the tip / trick but I still have it (An Unexpected HTTP Error occurred during the API request.) although I’ve done the steps as above. I’ve made changes to the file class-http.php but the result remains “An Unexpected HTTP Error occurred during the API request”.

  34. Andhi Irawan says:

    sorry I forgot to tell you that I am using WordPress Version 3.0. on previous versions I’ve never experienced this

  35. Rahul Dutta says:

    This has changed since WordPress 3.0

    Go to wp-includes and Edit the file “class-http.php “

  36. Chintan Kotadia says:

    Hello Sanjeev,

    The solution which you have mentioned in your blog is not working for me. I did everything which you have mentioned in your blog. Can you please help me out with these problem?

    Thannking you.

    Regards,

    Chintan Kotadia,
    Professional Softtech.

  37. boochie says:

    I used free host with wp 3.0.4 and when add new post the system inform “An Unexpected HTTP Error occurred during the API request.” Then
    try to find your info that you reccomened but didn’t see that.
    please help.

  38. Vivek says:

    why i am getting this problem

    WP HTTP Error: User has blocked requests through HTTP

    Please help me i am using WordPress 3.0.1.

  39. Jon Bolden says:

    Thanks for this! It worked perfectly and now I can install plugins on MAMP. Sweeeetttt!

  40. Cimax says:

    I am using wp 3.0.5 but cant resolve it. even i cant find “function request” part. is that different for wp 3.0.5 ??!!

  41. Tejaswini says:

    I have updated the post for newer versions of WordPress. Now you will find the timeout limit defined in class-http.php file in ‘wp-includes’ folder of your WordPress installation. Thank you for bringing this up.

Leave a Reply

(required)

(required)