Help: Can’t connect to local Bitcoin node using bitcoinrpc in Python.
I can’t for the life of me figure this out…
I had trouble port forwarding my machine to 8332, but 8333 seemed fine, so I ended up moving rpcport to 8334. It seems to be connected now, but I keep getting this error in the following Python script…
My Python script (named bitcoin104.py)
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
# rpc_user and rpc_password are set in the bitcoin.conf file
#rpc_user = "myusername"
#rpc_password = "myuserpass"
rpc_connection = AuthServiceProxy("http://myusername:(email protected):8334")
print(rpc_connection.get_info())
When I run it, the following error appears…
PS D:\PROJECTS\python38_env_bitcoin\src\hellobitcoin101> python .\bitcoin104.py
Traceback (most recent call last):
File ".\bitcoin104.py", line 8, in <module>
print(rpc_connection.get_info())
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
Below are all the options I set in the bitcoin.conf file in my bitcoin local directory…
*port=8333
timeout=30
printtoconsole=1
chain=main
#rpcallowip=127.0.0.1
rpcpassword=myuserpass
rpcport=8334
rpcuser=myusername
server=1*
I ended up annotating rpcallowip to give it the best chance of working…
Otherwise the node seems to be running fine, so I’m sure it’s running. When I first played around with the setup, I left the port open for a day and had external connections happening… so I think I got the setup. There may be something else I’m doing wrong in the bitcoin.conf file.
And since I switched from 8332 to port 8334, at least now I don’t get any computer/host blocking request messages. At least now it seems to be communicating with the node as well. But for some reason you don’t seem to like the query?
I have no idea what I’m doing wrong? Any help would be greatly appreciated as I’ve had my head against the monitor all day now….