<p><code>8333</code> is the node connection port. Since you didn't change the RPC port in the config file, the port you should connect to is <code>8332</code>.</p>

CC BY-SA 4.0
2018-08-03T00:52:59.230Z
Thank you! also for anyone having the same issue, I needed to change the request.httpMethod = "GET" to "POST" and the "getinfo" method to "getwalletinfo". :)
Fontaine
CC BY-SA 4.0
2018-08-03T00:54:27.720Z
AND I needed to change rpcallowip in the config file to rpcallowip=0.0.0.0/0
Fontaine
CC BY-SA 4.0
2018-08-02T07:45:28.290Z
2018-08-02T07:45:28.290Z
MCCCS
<p>I am running a full node which accepts incoming connections.</p>

<p>Here is my config file:</p>

<pre><code>rpcuser=bitcoinrpc
rpcpassword=somePassword
server=1
rest=1
daemon=1
</code></pre>

<p>Here is my swift code to curl to the node:</p>

<pre><code>let url = URL(string: "http://bitcoinrpc:somePassword@192.168.1.8:8333")
    var request = URLRequest(url: url!)
    request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
    request.httpMethod = "GET"
    request.httpBody = "{\"jsonrpc\":\"1.0\",\"id\":\"curltext\",\"method\":\"getinfo\",\"params\":[]}".data(using: .utf8)

        let task = URLSession.shared.dataTask(with: request) { (data, response, error) -&gt; Void in

            do {

                if error != nil {

                    print(error)

                } else {

                    if let urlContent = data {

                        do {

                            let jsonAddressResult = try JSONSerialization.jsonObject(with: urlContent, options: JSONSerialization.ReadingOptions.mutableLeaves) as! NSDictionary

                            print("jsonAddressResult = \(jsonAddressResult)")

                        } catch {


                        }
                    }
                }
            }
        }

    task.resume()

}
</code></pre>

<p>I am using port 8333 and the static IP I set is 192.168.1.8</p>

<p>I get the following error when executing the code:</p>

<pre><code>2018-08-02 12:04:53.659293+0800 BitSense[5596:568091] Task &lt;47A80E16-F0FE-4508-9C5D-3EFDD82B55FB&gt;.&lt;1&gt; HTTP load failed (error code: -1005 [4:-4])
2018-08-02 12:04:53.660223+0800 BitSense[5596:568092] Task &lt;47A80E16-F0FE-4508-9C5D-3EFDD82B55FB&gt;.&lt;1&gt; finished with error - code: -1005
Optional(Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={NSUnderlyingError=0x600000244650 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={NSErrorPeerAddressKey=&lt;CFData 0x600000280460 [0x107f6ac80]&gt;{length = 16, capacity = 16, bytes = 0x1002208dc0a801080000000000000000}, _kCFStreamErrorCodeKey=-4, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=http://bitcoinrpc:5bKc4zYHX6qvB9HjKK89Ms2h@192.168.1.8:8333/, NSErrorFailingURLKey=http://bitcoinrpc:5bKc4zYHX6qvB9HjKK89Ms2h@192.168.1.8:8333/, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-4, NSLocalizedDescription=The network connection was lost.})enter preformatted text here
</code></pre>

<bitcoin-core><json-rpc><ios>
How to Curl into Bitcoin node with Swift?
Fontaine
# How to Curl into Bitcoin node with Swift?

(Asked by: username_0 on 2018-08-02)

I am running a full node which accepts incoming connections.
Here is my config file:
rpcuser=bitcoinrpc
rpcpassword=somePassword
server=1
rest=1
daemon=1

Here is my swift code to curl to the node:
let url = URL(string: "http://bitcoinrpc:somePassword@192.168.1.8:8333")
    var request = URLRequest(url: url!)
    request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
    request.httpMethod = "GET"
    request.httpBody = "{\"jsonrpc\":\"1.0\",\"id\":\"curltext\",\"method\":\"getinfo\",\"params\":[]}".data(using: .utf8)

        let task = URLSession.shared.dataTask(with: request) { (data, response, error) -> Void in

            do {

                if error != nil {

                    print(error)

                } else {

                    if let urlContent = data {

                        do {

                            let jsonAddressResult = try JSONSerialization.jsonObject(with: urlContent, options: JSONSerialization.ReadingOptions.mutableLeaves) as! NSDictionary

                            print("jsonAddressResult = \(jsonAddressResult)")

                        } catch {


                        }
                    }
                }
            }
        }

    task.resume()

}

I am using port 8333 and the static IP I set is 192.168.1.8
I get the following error when executing the code:
2018-08-02 12:04:53.659293+0800 BitSense[5596:568091] Task <47A80E16-F0FE-4508-9C5D-3EFDD82B55FB>.<1> HTTP load failed (error code: -1005 [4:-4])
2018-08-02 12:04:53.660223+0800 BitSense[5596:568092] Task <47A80E16-F0FE-4508-9C5D-3EFDD82B55FB>.<1> finished with error - code: -1005
Optional(Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={NSUnderlyingError=0x600000244650 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={NSErrorPeerAddressKey={length = 16, capacity = 16, bytes = 0x1002208dc0a801080000000000000000}, _kCFStreamErrorCodeKey=-4, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=http://bitcoinrpc:5bKc4zYHX6qvB9HjKK89Ms2h@192.168.1.8:8333/, NSErrorFailingURLKey=http://bitcoinrpc:5bKc4zYHX6qvB9HjKK89Ms2h@192.168.1.8:8333/, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-4, NSLocalizedDescription=The network connection was lost.})enter preformatted text here

**Tags:** bitcoin-core, json-rpc, ios


---

## 1 answers

### Answer by username_1 on 2018-08-02. Score: 1 | Accepted answer

`8333` is the node connection port. Since you didn't change the RPC port in the config file, the port you should connect to is `8332`.

> **Comments:**
> **username_0**: Thank you! also for anyone having the same issue, I needed to change the request.httpMethod = "GET" to "POST" and the "getinfo" method to "getwalletinfo". :)  
> **username_0**: AND I needed to change rpcallowip in the config file to rpcallowip=0.0.0.0/0  

---

