title: Unable to Curl-php into same server Electrum
body: <p>NOTE: 
  <a href="https://stackoverflow.com/questions/20064271/how-to-use-basic-authorization-in-php-curl">How to use basic authorization in PHP curl</a> 
  Does not work for me.</p>
  
  <p>Trying to Curl into Electrum, but it looks like my access is denied. Electrum is on the same server as the php script. I have purposefully left out any command for the wallet for simplification purpose. Focusing on connecting first.</p>
  
  <p>When trying to CURL in terminal</p>
  
  <pre><code>curl --data-binary '{"id":"curltext","method":"addrequest","params":{"amount":"3.14","memo":"test"}}' http://user:pass@127.0.0.1:7777
  </code></pre>
  
  <p>Error Message</p>
  
  <pre><code>curl: (7) Failed to connect to 127.0.0.1 port 7777: Connection refused
  </code></pre>
  
  <p>EDIT: The above CURL Command in Terminal now works</p>
  
  <p>PHP</p>
  
  <pre><code>$password = 'root';         
  $username = 'password';
  $URL='http://127.0.0.1';   //Curl into own machine local ip is needed.
  $port = 7777;
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,$URL);
  curl_setopt($ch, CURLOPT_PORT, $port);
  curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
  
  $result=curl_exec($ch);
  
  if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); }
  
  $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);   
  
  curl_close ($ch);
  
  echo "&lt;br&gt;";
  var_dump($result);
  echo "&lt;br&gt;";
  var_dump($status_code);
  </code></pre>
  
  <p>Below is my error</p>
  
  <blockquote>
    <p>Error:</p>
    
    <p>bool(false) </p>
    
    <p>int(0)</p>
  </blockquote>
  
  <p>Below are my netstats. Port is open and listening.</p>
  
  <pre><code>Active Internet connections (only servers)
  Proto Recv-Q Send-Q Local Address           Foreign Address         State      
  tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
  tcp        0      0 127.0.0.1:7777          0.0.0.0:*               LISTEN     
  tcp6       0      0 :::22                   :::*                    LISTEN     
  tcp6       0      0 :::80                   :::*                    LISTEN           
  </code></pre>
  
  <p><code>PHP7, PHP-CURL &amp; CURL</code> are installed on linux Fedora 27. Webserver type <code>Apache 2.4</code> <code>Electrum 3.1.2</code></p>
  
  <pre><code>curl -v 127.0.0.1 7777
  </code></pre>
  
  <p>Returns:</p>
  
  <pre><code>Rebuilt URL to: 127.0.0.1/
  *   Trying 127.0.0.1...
  * TCP_NODELAY set
  * Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
  &gt; GET / HTTP/1.1
  &gt; Host: 127.0.0.1
  &gt; User-Agent: curl/7.55.1
  &gt; Accept: */*
  &gt; 
  &lt; HTTP/1.1 200 OK
  &lt; Date: Wed, 04 Apr 2018 18:22:14 GMT
  &lt; Server: Apache/2.4.29 (Fedora)
  &lt; X-Powered-By: PHP/7.1.15
  &lt; Transfer-Encoding: chunked
  &lt; Content-Type: text/html; charset=UTF-8
  &lt; 
  
  /*index.php code*/
  
  * Connection #0 to host 127.0.0.1 left intact
  * Rebuilt URL to: 7777/
  *   Trying 0.0.30.97...
  * TCP_NODELAY set
  * Immediate connect fail for 0.0.30.97: Invalid argument
  * Closing connection 1
  curl: (7) Couldn't connect to server
  </code></pre>