PHP Curl with port number issue


This is a problem using PHP with Curl (on hosted server). I am trying to control a remote device (LED state) on port54512 (for example). The$url includes theIP:port number concatenated with a short CGI command.

The following is a code fragment;

$sensorIP = ""; // IP:port format

$url = $sensorIP . "/setParam.cgi?DOStatus_02=0" ; // set E2210 LED off

echo $url; // 

$result =  accessURL ($url); // set LED state on E2210 remote unit  

This code times out. When I use the $url as an address in a web browser it works fine. So the receiving port 54512 is not blocked. When I useIP:80 to form$url it works fine (receiving port set to 80).I tried using theCURLOPT_PORT option and the PHP script still times out.

The sending server outgoing HTTP is NOT blocking any port numbers, I checked with my hosting company. They believe I have a programming error, but where?

Thanks! Al





  1. Try$sensorIP = "";

  2. Make sure the outbound port 54512 is open (check with your hosting provider)

  3. Aftercurl_exec() function, add$output = curl_getinfo($ch); and print and check the output. you can get some info from that.

  4. Dont include port number as part of url. Use the following instead:

    curl_setopt($ch, CURLOPT_PORT, '54512');




I came across the same problem lately. I've tried almost everything, but no luck yet As far as I understood, curl does not work with other ports except 80. So the best solution here is to address curl on port 80 and you won't have any problems as I do now. Hope this info will help you.

People are also looking for solutions to the problem: php - Empty date and time in mysql table


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.