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.

 

  • http://www.serradinho.com George Serradinho

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

  • http://choosyinfo.com Ruchi

    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 ?

  • http://izzataziz.net/blog izzat aziz

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

  • http://www.bytechip.com Ramkumar

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

  • http://www.clickonf5.org Sanjeev Mishra

    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.

  • http://www.clickonf5.org Sanjeev Mishra

    I am glad that the solution helped you. Thanks

  • http://www.blogrpro.com BlogrPro

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

  • http://www.hellboundbloggers.com/about/ S.Pradeep Kumar

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

  • http://coolwebgossip greg

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

  • http://sexybookmarks.net Josh

    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.

  • http://sexybookmarks.net Josh

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

  • http://www.clickonf5.org Sanjeev Mishra

    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.

  • Jason

    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?

  • http://www.hasrimy.com Sunny Khiani

    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

  • http://blog.andreabravo.me Andrea

    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

  • Ejaz

    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

  • simrandeep singh

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

  • http://oolat.com zoul

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

    Thanks again

  • http://aboutpipesmoking.com/ Marcin

    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.

  • Mandy

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

  • http://dietonautopilot.com Claudia

    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!

  • Ejaz

    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

  • http://www.smashinghub.com Ali Qayyum

    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

  • http://www.ihomecash.com rie

    Hi, Sanjeev.

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

  • http://umbrellamediacenter.com Burns

    Thanks a lot. is solved my problem

  • http://www.reader.co.il/authors/13942/%D7%A4%D7%99%D7%98%D7%A8-%D7%9E%D7%99%D7%98%D7%A9%D7%9C Ozell Claiborne

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

  • http://www.angelaneal.com Sparklyscotty

    Thanks! :D

  • RicardoRmz

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

  • http://www.windweit.de Gabi

    Thanks both to you and RicardoRmz!

  • http://digitalwarez.in digitalwarez

    thanx a lot………worked grt

  • http://www.rahinur.com/ Rahinur Rahaman

    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.

  • http://www.djumtks.co.cc dJumTKS Weblog

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

  • Andhi Irawan

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

  • Andhi Irawan

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

  • Rahul Dutta

    This has changed since WordPress 3.0

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

  • http://www.professionalsofttech.com/wordpress/ Chintan Kotadia

    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.

  • http://www.lowpriceplaza.com boochie

    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.

  • Vivek

    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.

  • http://www.jonbolden.com Jon Bolden

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

  • http://www.pcforum.cimax.se Cimax

    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 ??!!

  • http://www.clickonf5.org Tejaswini

    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.