<p>I have downloaded and installed and got up and running a bitcoin core node, and it is running fine as far as people are connecting to it on port 8333 just fine.  However I can't seem to connect to it myself on the same machine using python bitcoinrpc library...</p>
<p>My .conf files looks like...</p>
<pre><code>port=8333
timeout=10000
printtoconsole=1
chain=main
rpcuser=one
rpcport=8334
#rpcauth=one:xxxxxx
server=1
coinstatsindex=1
daemon=1
txindex=1
</code></pre>
<p>and my python app..</p>
<pre><code>from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException

# rpc_user and rpc_password are set in the bitcoin.conf file
rpc_user = &quot;one&quot;
rpc_password = &quot;two&quot;
rpc_connection = AuthServiceProxy(&quot;http://%s:%s@127.0.0.1:8334&quot;%(&quot;one&quot;,&quot;two&quot;))

best_block_hash = rpc_connection.getbestblockhash()
</code></pre>
<p>And when it runs it fails on line</p>
<pre><code>best_block_hash = rpc_connection.getbestblockhash()
</code></pre>
<p>with the following error...</p>
<pre><code>Traceback (most recent call last):
  File &quot;.\bitcoin104.py&quot;, line 10, in &lt;module&gt;
    best_block_hash = rpc_connection.getbestblockhash()
  File &quot;D:\PROJECTS\python38_env_bitcoin\.venv\lib\site-packages\bitcoinrpc\authproxy.py&quot;, line 139, in __call__
    response = self._get_response()
  File &quot;D:\PROJECTS\python38_env_bitcoin\.venv\lib\site-packages\bitcoinrpc\authproxy.py&quot;, line 179, in _get_response
    http_response = self.__conn.getresponse()
  File &quot;c:\users\hanso\appdata\local\programs\python\python38\lib\http\client.py&quot;, line 1344, in getresponse
    response.begin()
  File &quot;c:\users\hanso\appdata\local\programs\python\python38\lib\http\client.py&quot;, line 307, in begin
    version, status, reason = self._read_status()
  File &quot;c:\users\hanso\appdata\local\programs\python\python38\lib\http\client.py&quot;, line 276, in _read_status
    raise RemoteDisconnected(&quot;Remote end closed connection without&quot;
http.client.RemoteDisconnected: Remote end closed connection without response
</code></pre>
<p>I have checked all my ports, and I am certain they are working, they work through telnet, the netstat -a shows the ports are listening when i open the bitcoin core node, and when i try a different port I get a different error complaining about host connection was refused. So I am 99% certain the port forwarding and firewall is open to the desired ports.  Port 8333 for outside connections shows a log of people connecting to the server. So I am almost certain it is not the machine, firewall, or router not allowing connections through the port.</p>
<p>That leaves either something I am setting up wrong with the password.  I changed the setup to use a simple one, two useid and password for testing, and so I can post here to show exactly what I am doing word for word in the conf and the python script.</p>
<p>I am really pounding my head against the wall.. Is it possible something to do with rpcauth... i tried running that and creating a hash and then tried to use that as a replacement in my http://pass:key@127.0.0,1:8334 connection. But it doesnt' seem to work either.  But funny enough when I type the clearly wrong password in i get the same error I am getting now.  But if I change say the ip address then it fails up on the AuthServiceProxy creation line instead. And the issue says that the machine host refused connection. So all this points to the node node liking my userid and/or password but I can't find any examples to know for sure I am setting these up correctly for the node in the .conf file before launching node, or if i am doing something wrong in the python script?</p>

CC BY-SA 4.0
2024-02-01T06:10:50.007Z
Is the rpcauth line actually commented out in your bitcoin.conf?
Vojtěch Strnad
CC BY-SA 4.0
2024-02-01T16:45:01.877Z
yea, I wasn't quite sure if I needed it. I tried using it, but i am not sure exactly then what i use in the python call ie what goes in the AuthServiceProxy() initialization function?
I ran the app include in bitcoin core to get that number, but I wasn't sure how I am suppose to use it.  So I commented it out after using it and it didn't work.  And went back to what i have seen in the very few case examples I could find, which didn't seem to include it..
The Journey
CC BY-SA 4.0
2024-02-06T18:18:43.440Z
In your bitcoin.conf file, there should be, uncommented an rpcuser= and rpcpassword= pair of lines. Alternatively, you can have an rpcauth= line which specifies username and password together, salted (for more info see https://github.com/jlopp/bitcoin-core-rpc-auth-generator). But if you don't have either one or the other, then you haven't really specified a username and password pair, so you can't authenticate.
alexg
CC BY-SA 4.0
2024-03-17T20:42:06.200Z
@alexg I definitely had both the rpcpassword and rpcuser, as well as tried the rcpauth method as well, Neither worked... but it seems to at least be partially working as when I change it, it get a different error, indicating it seems to be picking it up?

Could it be the issue is sending the message back?
The Journey
CC BY-SA 4.0
2024-03-19T06:31:24.337Z
@TheJourney Without knowing what the new error is, it's hard to tell... In any case, if you are using rpcuser= and rpcpassword= instead of rpcauth= then your password cannot contain the equals sign (=). If you are using rpcauth then the password can contain any character because it's encoded.
alexg
<bitcoin-core><json-rpc><python>
Bitcoin Core RPC server not working
The Journey
# Bitcoin Core RPC server not working

(Asked by: username_0 on 2024-01-31)

I have downloaded and installed and got up and running a bitcoin core node, and it is running fine as far as people are connecting to it on port 8333 just fine. However I can't seem to connect to it myself on the same machine using python bitcoinrpc library...

My .conf files looks like...

```
port=8333
timeout=10000
printtoconsole=1
chain=main
rpcuser=one
rpcport=8334
#rpcauth=one:xxxxxx
server=1
coinstatsindex=1
daemon=1
txindex=1

```

and my python app..

```
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException

# rpc_user and rpc_password are set in the bitcoin.conf file
rpc_user = "one"
rpc_password = "two"
rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8334"%("one","two"))

best_block_hash = rpc_connection.getbestblockhash()

```

And when it runs it fails on line

```
best_block_hash = rpc_connection.getbestblockhash()

```

with the following error...

```
Traceback (most recent call last):
  File ".\bitcoin104.py", line 10, in <module>
    best_block_hash = rpc_connection.getbestblockhash()
  File "D:\PROJECTS\python38_env_bitcoin\.venv\lib\site-packages\bitcoinrpc\authproxy.py", line 139, in __call__
    response = self._get_response()
  File "D:\PROJECTS\python38_env_bitcoin\.venv\lib\site-packages\bitcoinrpc\authproxy.py", line 179, in _get_response
    http_response = self.__conn.getresponse()
  File "c:\users\hanso\appdata\local\programs\python\python38\lib\http\client.py", line 1344, in getresponse
    response.begin()
  File "c:\users\hanso\appdata\local\programs\python\python38\lib\http\client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "c:\users\hanso\appdata\local\programs\python\python38\lib\http\client.py", line 276, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

```

I have checked all my ports, and I am certain they are working, they work through telnet, the netstat -a shows the ports are listening when i open the bitcoin core node, and when i try a different port I get a different error complaining about host connection was refused. So I am 99% certain the port forwarding and firewall is open to the desired ports. Port 8333 for outside connections shows a log of people connecting to the server. So I am almost certain it is not the machine, firewall, or router not allowing connections through the port.

That leaves either something I am setting up wrong with the password. I changed the setup to use a simple one, two useid and password for testing, and so I can post here to show exactly what I am doing word for word in the conf and the python script.

I am really pounding my head against the wall.. Is it possible something to do with rpcauth... i tried running that and creating a hash and then tried to use that as a replacement in my http://pass:key@127.0.0,1:8334 connection. But it doesnt' seem to work either. But funny enough when I type the clearly wrong password in i get the same error I am getting now. But if I change say the ip address then it fails up on the AuthServiceProxy creation line instead. And the issue says that the machine host refused connection. So all this points to the node node liking my userid and/or password but I can't find any examples to know for sure I am setting these up correctly for the node in the .conf file before launching node, or if i am doing something wrong in the python script?

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

> **Comments:**
> **username_1**: Is the rpcauth line actually commented out in your bitcoin.conf?  
> **username_0**: yea, I wasn't quite sure if I needed it. I tried using it, but i am not sure exactly then what i use in the python call ie what goes in the AuthServiceProxy() initialization function? I ran the app include in bitcoin core to get that number, but I wasn't sure how I am suppose to use it.  So I commented it out after using it and it didn't work.  And went back to what i have seen in the very few case examples I could find, which didn't seem to include it..  
> **username_2**: In your bitcoin.conf file, there should be, uncommented an rpcuser= and rpcpassword= pair of lines. Alternatively, you can have an rpcauth= line which specifies username and password together, salted (for more info see https://github.com/jlopp/bitcoin-core-rpc-auth-generator). But if you don't have either one or the other, then you haven't really specified a username and password pair, so you can't authenticate.  
> **username_0**: @username_2 I definitely had both the rpcpassword and rpcuser, as well as tried the rcpauth method as well, Neither worked... but it seems to at least be partially working as when I change it, it get a different error, indicating it seems to be picking it up?  Could it be the issue is sending the message back?  
> **username_2**: @username_0 Without knowing what the new error is, it's hard to tell... In any case, if you are using rpcuser= and rpcpassword= instead of rpcauth= then your password cannot contain the equals sign (=). If you are using rpcauth then the password can contain any character because it's encoded.  

---

## 0 answers

