Unable to make php curl request with port number
Try to set the port like this:
curl_setopt($ch, CURLOPT_PORT, $_SERVER['SERVER_PORT']);
or:
curl_setopt($ch, CURLOPT_PORT, 8088);
make a php curl with port number
Your server most likely have a firewall rule blocking outgoing access for unusual ports.
Can curl make a connection to any TCP ports, not just HTTP/HTTPS?
Since you're using PHP, you will probably need to use the CURLOPT_PORT
option, like so:
curl_setopt($ch, CURLOPT_PORT, 11740);
Bear in mind, you may face problems with SELinux:
Unable to make php curl request with port number
PHP Curl on 81 port
Try this
curl_setopt ($ch, CURLOPT_PORT , 81);
Update code:-
see this URL:- php curl problem
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_URL, 'http://27.4.198.225:81/ncmsl/check.php');
$store = curl_exec ($ch);
echo substr($store, 1);
curl_close ($ch);
POST data with Curl on a specific port with HTTPS
Try to setting the port number like this:
curl_setopt($curl, CURLOPT_PORT, 8088);
where 8088 is your real port number.
Also the proper way of handling the SSL requests involves setting the CURLOPT_CAINFO
parameter:
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_CAINFO, getcwd() . "/folder/your-secure-certificate.crt");
This ensures that not just any server certificate will be trusted by your cURL
session.
For example, if an attacker were to somehow redirect traffic from api.example.com
to their own server, the cURL
session here would not properly initialize, since the attacker would not have access to a server certificate (i.e. would not have the private key) trusted by the CA we added.
EDIT:
Many hosting companies don't allow connections "back" to your own host from your own PHP programs so perhaps that's what's happening here. Also try to apply the proxy settings, which is used in your LAN and see if it works, add this to your code if necessary:
$proxy = '127.0.0.1:8888';
curl_setopt($curl, CURLOPT_PROXY, $proxy);
IP URL with Port is not working in cURL PHP
I would test if the port is open. You can use telnet IP PORT
. High chance the port is being blocked. Another possibility is that you're trying to connect to a port which forces SSL. Which you have clearly inactivated in your code. Try generating a valid certificate and try again.
Related Topics
Setting a Cookie in an Ajax Request
Saving File Using Curl and PHP
How to Iterate by Row Through a MySQL Query in PHP
Sort Array by Value Alphabetically PHP
Phpmailer Attachment, Doing It Without a Physical File
How to Upload a File Using Jquery's $.Ajax Function with JSON and PHP
Run PHP Function Inside Jquery Click
Finding Common Value Among Sub-Arrays in a Multidimensional Array
Echo PHP Variable from JavaScript
What's the Best Way/Practice to Get the Extension of a Uploaded File in PHP
Eloquent Groupby Make "Sqlstate[42000]" with Valid SQL Query in Laravel 5.3
Escaping SQL Queries in Codeigniter