WordPress solves the problem of "an HTTP Error occurred when requesting an API ".

Source: Internet
Author: User
Tags in domain

WordPress solves the problem of "an HTTP Error occurred when requesting an API ".

1. The main reason is that the fsockopen () function is disabled on the host (). The API cannot be called.

Solution: Open/WP-nodes des/class-http.php lookup @ fsockopen (replace with @ pfsockopen (

Find fsockopen (replace with pfsockopen (

Note: Do not replace wp_http_fsockopen (

2. There is another method:

Modify line 220th of WP-DES/class-http.php

'Timeout' => apply_filters ('HTTP _ request_timeout', 5 ),

The value 5 is changed to a large number. The value 5 indicates the request time, in seconds, that is, 5 seconds timeout.


3. Linux I configured locally does not experience timeout. On the other hand, Linux has timed out. Why, later, I unlocked the Code layer by layer, and found that it was slow in domain name resolution. When WP is updated online, it is connected to api.wordpress.org, for example, when installing the template, connect http://api.wordpress.org/themes/info/1.0/, wget http://api.wordpress.org/themes/info/1.0/
and wget http://api.wordpress.org/themes/info/1.0/ speed varies a lot. Later, I changed/etc/resolv. conf to 8.8.8.8.8.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.