<p>So first you want to make sure that Bitcoin core is running. May seem obvious but I've forgotten that sometimes.</p>
<p>Next is the port forwarding. This may be the source of your problem.</p>
<p>You're going to want to go into your ethernet settings and network connection details. In there you will see an IPv4 address, something like 192.168.0.xx. Save that number.</p>
<p>Now go into your router settings, setup a TCP service on 8333 and put the IPv4 into the internal IP section and save.</p>
<p>Now to call this in python I use bitcoinlib.</p>
<p>my code looks like this:</p>
<pre><code>from bitcoinlib.services.authproxy import AuthServiceProxy, JSONRPCException


def rpcConnect():
    try:
        rpc_connection = AuthServiceProxy(&quot;http://user:pass@127.0.0.1:8332&quot;)
        return rpc_connection
</code></pre>
<p>My bitcoin conf looks like this. Some of these may not be relevant to you</p>
<pre><code>coinstatsindex=1
daemon=1
txindex=1

server=1
prune=0
peerbloomfilters=1

rpcuser=***
rpcpassword=***
rpcport=8332
</code></pre>

CC BY-SA 4.0
2024-01-30T17:56:08.880Z
Thanks @user2880722. I have already done the port forwarding on my local mesh router system setup.  I added it specifically to my own machine.  For some reason I could not for the life of my get 8332 open.  I see 8333 is working fine when i run telnet or netstat -a. So I finally ended up trying 8334, and that worked it seems, at least I was able to telnet to it, where 8332 just would not work. Even after opening on myfirewall and router in as many ways as I could think to try...
The Journey
CC BY-SA 4.0
2024-01-30T17:56:13.363Z
But I never had several of the options you had... namely..
coinstatsindex=1
daemon=1
txindex=1

So I am going to try those again.  I will definitely try to see if my forwarding is working properly on my firewall and my router again, just to make sure.

At work now so will try this later this evening and post how it went. Really hoping to figure this out as so frustrating... ;)

Again thanks for the help!!!
The Journey
CC BY-SA 4.0
2024-01-31T19:29:30.353Z
I have tried everything.
I am certain my port is open, as when I telnet to it, it connects just fine.
And when i use netstat -a, it shows up as 'listening' which wasn't happening before I set that port, so i think it isn't port forwarding or firewall issues.

And when I run this...
rpc_connection = AuthServiceProxy("http://username:userpassword@127.0.0.1:8334")

It seems to run no problem,.. but then when i try this right after..
print(rpc_connection.get_info())
It fails with the error...
http.client.RemoteDisconnected: Remote end closed connection without response

So frustrating.
The Journey
CC BY-SA 4.0
2024-01-31T20:38:14.670Z
I am sure the connection is working now. it is the password I am now questioning..
But I dont' know what i could be wrong?

my password is set as follows...
rpcuser=one
rpcpassword=two

is there supposed to be quotes around the password and user id?  The example .conf files I have seen had none of that.
I am starting to think I might need to reopon this question and start again, and ask about how authorization, and what might be my issue on that front.  As everything I confirmed my ports are open, and listening, it is just the server that seems to have some issue granting my request
The Journey
CC BY-SA 4.0
2024-01-30T12:45:50.577Z
2024-01-30T12:45:50.577Z
user2880722
<p>For the life of me I can't figure this out...</p>
<p>I was having trouble getting my machine to port forward 8332, but 8333 seemed fine, so I ended up moving my rpcport to 8334, which seems to connect now but I keep getting this error now on the following python script...</p>
<p>My Python Script(named bitcoin104.py)</p>
<pre class="lang-python prettyprint-override"><code>from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
# rpc_user and rpc_password are set in the bitcoin.conf file
#rpc_user = &quot;myusername&quot;
#rpc_password = &quot;myuserpass&quot;
rpc_connection = AuthServiceProxy(&quot;http://myusername:myuserpass@127.0.0.1:8334&quot;)
print(rpc_connection.get_info())
</code></pre>
<p>When i run it I get the following error...</p>
<pre><code>PS D:\PROJECTS\python38_env_bitcoin\src\hellobitcoin101&gt; python .\bitcoin104.py
Traceback (most recent call last):
  File &quot;.\bitcoin104.py&quot;, line 8, in &lt;module&gt;
    print(rpc_connection.get_info())
  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>Here are all the options i have set in my bitcoin.conf file in my local directory for bitcoin...</p>
<pre><code>*port=8333
timeout=30
printtoconsole=1
chain=main
#rpcallowip=127.0.0.1
rpcpassword=myuserpass
rpcport=8334
rpcuser=myusername
server=1*
</code></pre>
<p>I ended up commenting out rpcallowip just to give it the best chance of working...</p>
<p>Should also note the node seems to be running fine otherwise, so it is definitely up and running, and when I was first playing around with setup I left the port open for a day and had outside connections happening... So i think that is setup ok. Other then possible something I am doing wrong with the bitcoin.conf file.</p>
<p>And since I switched to port 8334 from 8332 I am at least now not getting a machine/host blocked request message.  It seems to at least be communicating with the node now as well. But for some reason it doesn't seem to like the query?</p>
<p>I have no idea what I am doing wrong?  Any help would be greatly appreciated as have been banging my head against the monitor all day on this now....</p>

CC BY-SA 4.0
2024-01-29T03:44:14.483Z
What were the router settings when you forwarded 8333?
user2880722
CC BY-SA 4.0
2024-01-29T13:28:00.093Z
On what computer are you running the python-script?
Are you running the python script and your bitcoin-node on the same machine?
Erik
CC BY-SA 4.0
2024-01-30T09:30:33.390Z
@user2880722 They were set for port forwarding on the ports i was attempting to connect through.  When i had that not setup, i got a 'connection refused by computer', but when I added the port forwarding it stopped giving that error, and now gives the error above about timing out.  Which makes me feel like it is actually not the portforwarding or firewall blocking issue now.....?
The Journey
CC BY-SA 4.0
2024-01-30T09:41:43.857Z
@Erik I was using the same machine the node is running on.  Hence connection using the 127.0.0.01 address.  Do you think I should try using my full address on my router instead?  ie for example 192.168.68.XX

Not sure if I mentioned but running on windows 11 machine.  

I feel like it is connecting now, at least partially, only because when I got opening port wrong i get a different error talking about the computer refusing connection. Now at least I am getting the "Remote end closed connection without response". It really feels like I am connecting... thought, definitely could be wrong...
The Journey
CC BY-SA 4.0
2024-01-30T09:44:57.973Z
I wish I could see a working conf file, and matching python script using the rpc routines, then at least I could know how it is supposed to work. Right now I feel like I get only pieces, or examples setup on a cloud computer through one of those notebook sites, which I am sure don't have the same issues a real computer setup has like I am trying?
It's frustrating because I Have no idea what to try next. 

Also I should mention I also can connect to my port using telnet just fine now, another reason I believe the port is available.
The Journey
CC BY-SA 4.0
2024-01-30T11:00:34.733Z
Should also mention telnet works on that port.
But when i use netstat -a I see port 8333 is listed as 'listening. But the port i set for listening for rpcport is not shown on the netstat -a list.  I am not sure if that shows the connection is not setup properly?
Are there any settings in the qt window that also need to be turned on, ie when I run bitcoin-qt.exe?
The Journey
CC BY-SA 4.0
2024-01-31T19:32:58.977Z
I am almost certain now the port is listening, and open...
But i have checked my password like a hundred times...
So frustrating.. is there a setting on the actually qt interface I may have accidently set wrong?
The Journey
<bitcoin-core>
Help: Unable to connect using bitcoinrpc in python to my local bitcoin node
The Journey
# Help: Unable to connect using bitcoinrpc in python to my local bitcoin node

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

For the life of me I can't figure this out...

I was having trouble getting my machine to port forward 8332, but 8333 seemed fine, so I ended up moving my rpcport to 8334, which seems to connect now but I keep getting this error now on the following python script...

My Python Script(named bitcoin104.py)

```python
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:myuserpass@127.0.0.1:8334")
print(rpc_connection.get_info())

```

When i run it I get the following error...

```
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

```

Here are all the options i have set in my bitcoin.conf file in my local directory for bitcoin...

```
*port=8333
timeout=30
printtoconsole=1
chain=main
#rpcallowip=127.0.0.1
rpcpassword=myuserpass
rpcport=8334
rpcuser=myusername
server=1*

```

I ended up commenting out rpcallowip just to give it the best chance of working...

Should also note the node seems to be running fine otherwise, so it is definitely up and running, and when I was first playing around with setup I left the port open for a day and had outside connections happening... So i think that is setup ok. Other then possible something I am doing wrong with the bitcoin.conf file.

And since I switched to port 8334 from 8332 I am at least now not getting a machine/host blocked request message. It seems to at least be communicating with the node now as well. But for some reason it doesn't seem to like the query?

I have no idea what I am doing wrong? Any help would be greatly appreciated as have been banging my head against the monitor all day on this now....

**Tags:** bitcoin-core

> **Comments:**
> **username_1**: What were the router settings when you forwarded 8333?  
> **username_2**: On what computer are you running the python-script? Are you running the python script and your bitcoin-node on the same machine?  
> **username_0**: @username_1 They were set for port forwarding on the ports i was attempting to connect through.  When i had that not setup, i got a 'connection refused by computer', but when I added the port forwarding it stopped giving that error, and now gives the error above about timing out.  Which makes me feel like it is actually not the portforwarding or firewall blocking issue now.....?  
> **username_0**: @username_2 I was using the same machine the node is running on.  Hence connection using the 127.0.0.01 address.  Do you think I should try using my full address on my router instead?  ie for example 192.168.68.XX  Not sure if I mentioned but running on windows 11 machine.    I feel like it is connecting now, at least partially, only because when I got opening port wrong i get a different error talking about the computer refusing connection. Now at least I am getting the "Remote end closed connection without response". It really feels like I am connecting... thought, definitely could be wrong...  
> **username_0**: I wish I could see a working conf file, and matching python script using the rpc routines, then at least I could know how it is supposed to work. Right now I feel like I get only pieces, or examples setup on a cloud computer through one of those notebook sites, which I am sure don't have the same issues a real computer setup has like I am trying? It's frustrating because I Have no idea what to try next.   Also I should mention I also can connect to my port using telnet just fine now, another reason I believe the port is available.  
> **username_0**: Should also mention telnet works on that port. But when i use netstat -a I see port 8333 is listed as 'listening. But the port i set for listening for rpcport is not shown on the netstat -a list.  I am not sure if that shows the connection is not setup properly? Are there any settings in the qt window that also need to be turned on, ie when I run bitcoin-qt.exe?  
> **username_0**: I am almost certain now the port is listening, and open... But i have checked my password like a hundred times... So frustrating.. is there a setting on the actually qt interface I may have accidently set wrong?  

---

## 1 answers

### Answer by username_1 on 2024-01-30. Score: 0

So first you want to make sure that Bitcoin core is running. May seem obvious but I've forgotten that sometimes.

Next is the port forwarding. This may be the source of your problem.

You're going to want to go into your ethernet settings and network connection details. In there you will see an IPv4 address, something like 192.168.0.xx. Save that number.

Now go into your router settings, setup a TCP service on 8333 and put the IPv4 into the internal IP section and save.

Now to call this in python I use bitcoinlib.

my code looks like this:

```
from bitcoinlib.services.authproxy import AuthServiceProxy, JSONRPCException

def rpcConnect():
    try:
        rpc_connection = AuthServiceProxy("http://user:pass@127.0.0.1:8332")
        return rpc_connection

```

My bitcoin conf looks like this. Some of these may not be relevant to you

```
coinstatsindex=1
daemon=1
txindex=1

server=1
prune=0
peerbloomfilters=1

rpcuser=***
rpcpassword=***
rpcport=8332

```

> **Comments:**
> **username_0**: Thanks @username_1. I have already done the port forwarding on my local mesh router system setup.  I added it specifically to my own machine.  For some reason I could not for the life of my get 8332 open.  I see 8333 is working fine when i run telnet or netstat -a. So I finally ended up trying 8334, and that worked it seems, at least I was able to telnet to it, where 8332 just would not work. Even after opening on myfirewall and router in as many ways as I could think to try...  
> **username_0**: But I never had several of the options you had... namely.. coinstatsindex=1 daemon=1 txindex=1  So I am going to try those again.  I will definitely try to see if my forwarding is working properly on my firewall and my router again, just to make sure.  At work now so will try this later this evening and post how it went. Really hoping to figure this out as so frustrating... ;)  Again thanks for the help!!!  
> **username_0**: I have tried everything. I am certain my port is open, as when I telnet to it, it connects just fine. And when i use netstat -a, it shows up as 'listening' which wasn't happening before I set that port, so i think it isn't port forwarding or firewall issues.  And when I run this... rpc_connection = AuthServiceProxy("http://username:userpassword@127.0.0.1:8334")  It seems to run no problem,.. but then when i try this right after.. print(rpc_connection.get_info()) It fails with the error... http.client.RemoteDisconnected: Remote end closed connection without response  So frustrating.  
> **username_0**: I am sure the connection is working now. it is the password I am now questioning.. But I dont' know what i could be wrong?  my password is set as follows... rpcuser=one rpcpassword=two  is there supposed to be quotes around the password and user id?  The example .conf files I have seen had none of that. I am starting to think I might need to reopon this question and start again, and ask about how authorization, and what might be my issue on that front.  As everything I confirmed my ports are open, and listening, it is just the server that seems to have some issue granting my request  

---

