title: Failed to connect to : Connection refused - cURL PHP
body: <p>So here's the scenario.</p>
  
  <p>1) On my local machine that is running MAMP, I'm not facing any issue and I'm able to successfully get the response along with <code>CURLINFO_HTTP_CODE=200</code></p>
  
  <p>2) However, there is a remote server on which my PHP code is deployed. If I try to run the same thing (as I've mentioned in #1) I get an error that says </p>
  
  <p><code>curl_error = Failed to connect to my_ip port my_port: Connection refused</code> with <code>CURLINFO_HTTP_CODE = 7</code></p>
  
  <pre><code>$url = 'myURL';
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  curl_setopt($ch, CURLOPT_VERBOSE, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch,CURLOPT_CONNECTTIMEOUT ,30); //timeout in seconds
  curl_setopt($ch,CURLOPT_TIMEOUT, 20); // same for here. Timeout in seconds.
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
          'Content-Type: application/json',
          'Content-Length: ' . strlen($data_string))
  );
  </code></pre>
  
  <p><code>
  </code>$data_string = {"name":"mark"}  `</p>