PHP cURL To Custom Ports (Flask)
If you are having issues using cURL in PHP to a non-standard port (e.g 80, 443) then most like you have not added the CURLOPT_PORT.
If you are having issues using cURL in PHP to a non-standard port (e.g 80, 443) then most like you have not added the CURLOPT_PORT. This tells cURL to use a different port, this should be used like this:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://0.0.0.0/end_point");
curl_setopt($ch, CURLOPT_PORT, 3000);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
The PHP manual simply states it should be set to 'An alternative port number to connect to'. It is important to note that the port number should be removed from the URL when using this.
PHP: curl_setopt - Manual
Comments ()