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




I actually got this message yesterday and I had no clue what was going on. Thanks for sharing this, helps me out a lot.
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 ?
i often get the error.. thank for the tips it really helpful.. because i hate to refresh over and over..
I havnt faced this problem yet, but will be very helpful if it happens in future.
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.
I am glad that the solution helped you. Thanks
So far I didn’t face this problem. But will try this to avoid in future.
Cool buddy.. I got this error last week.. when trying to edit and open my posts… thanks a lot..
Thanks for a great tip – I too get this problem frequently!
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.
Sorry, forgot to leave the direct link for you: http://wordpress.org/support/topic/227430
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.
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?
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
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
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
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…..
Thanks.. you’re really help me a lot in this matter..
Thanks again
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.
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!!!
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!
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
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
Hi, Sanjeev.
I got this error while trying to add new plugin for my blog. This info helps me to solve it. Thank you:-)
Thanks a lot. is solved my problem
Useful post. Lucky me I discovered your web-site by indicent, I bookmarked it so I can locate it next time.
Thanks!
On WordPress 3.0 this function is declared on wp-includes/class-http.php (line 220)
Thanks both to you and RicardoRmz!
thanx a lot………worked grt
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.
hello sanjeev, thank you for your post, it solved my problem
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”.
sorry I forgot to tell you that I am using WordPress Version 3.0. on previous versions I’ve never experienced this
This has changed since WordPress 3.0
Go to wp-includes and Edit the file “class-http.php “
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.
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.
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.
Thanks for this! It worked perfectly and now I can install plugins on MAMP. Sweeeetttt!
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 ??!!
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.