Couldn 'tconnecttohost exception reported by using curl

Source: Internet
Author: User
Using curl to report couldntconnecttohost error PHPcode sends post request function_xpost ($ url, $ p) {$ f; $ data; foreach ($ pas $ k & gt; $ v) {$ data. $ f. $ k .. when urlencode ($ v) uses curl to report a couldn't connect to host error
PHP code
  // Send the post request function _ xpost ($ url, $ p) {$ f = ''; $ data =''; foreach ($ p as $ k => $ v) {$ data. = $ f. $ k. '= '. urlencode ($ v); // $ data. = $ f. $ k. '= '. $ v; $ f = '&';} // echo $ data.'
'; $ Curl = curl_init ($ url); curl_setopt ($ curl, expires, 1); curl_setopt ($ curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt ($ curl, expires, 1); curl_setopt ($ curl, CURLOPT_POST, 1); curl_setopt ($ curl, CURLOPT_POSTFIELDS, $ data); $ res = curl_exec ($ curl ); if (curl_errno ($ curl) {echo 'curl error :'. curl_error ($ curl);} curl_close ($ curl); return $ res ;}

I call this function and send a text message, which can run normally on the local server. However, the Curl error: couldn't connect to host error is reported when deployed on the network server, what's going on? Solution

------ Solution --------------------
You can ping the host URL on the server to see if it works?

It may be because the DNS server settings of the server are incorrect, and the host cannot be found. In addition, if the ip address of your server is blocked by the other party, this prompt will appear.
------ Solution --------------------
Agree upstairs
------ Solution --------------------
Can you connect with foskopen?

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.