<h3>Minimal bitcoin.conf</h3>
<p>You quoted</p>
<pre><code>  File &quot;c:\users\hanso\appdata\local\programs\python\python38\lib\socket.py&quot;, line 669, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out
</code></pre>
<p><strong>Pay attention to that last line</strong></p>
<hr />
<p>With this bitcoin.conf</p>
<pre><code>rpcuser=today
rpcpassword=temporary
</code></pre>
<p>This python script, in a file named <code>GetBlockCount.py</code></p>
<pre><code>from bitcoinrpc.authproxy import AuthServiceProxy

rpc_user =&quot;today&quot;
rpc_password=&quot;temporary&quot;
rpc_port = &quot;8332&quot;

rpc_client = AuthServiceProxy(&quot;http://%s:%s@127.0.0.1:%s&quot;%(rpc_user, rpc_password, rpc_port), timeout=120)

block_count = rpc_client.getblockcount()
print(block_count)
</code></pre>
<p>Produces this result</p>
<pre><code>C&gt; python GetBlockCount.py
827496
</code></pre>
<p><strong>Take careful note of that <code>timeout=120</code> in the script.</strong></p>
<hr />
<h3>Notes</h3>
<p>The above result was produced on an old and ordinary PC purchased in 2015 running Windows 10. It has an i7 processor, 8GB RAM and an ordinary HDD (not SSD).</p>
<p>The RPC service was provided by bitcoin-qt with RPC enabled in settings, options, main.</p>
<p>At the time I ran the script, Bitcoin core was about 1500 blocks behind. The script took nearly two minutes to return a result. It also produced a timeout before I increased the bitcoinrpc library default from 30 to 120.</p>
<p>After Bitcoin Core caught up, I find the python script returns a result in about three seconds. It is faster on subsequent invocations.</p>
<p>So when experiencing timeout error messages, I would either increase the timeout in the script or wait until Bitcoin core has fully synchronised.</p>
<p>The above is somewhat anecdotal. I wouldn't put too much weight on a single informal experiment.</p>
<hr />
<h2>Related</h2>
<ul>
<li><a href="https://bitcoin.stackexchange.com/questions/118921/error-unable-to-start-http-server-see-debug-log-for-details">Error: Unable to start HTTP server. See debug log for details</a></li>
<li><a href="https://bitcoin.stackexchange.com/q/89294/13866">Strange re-connection problem with python-bitcoinrpc</a></li>
</ul>

CC BY-SA 4.0
2024-02-04T03:28:14.640Z
Thanks man. I tried this, exactly word for word.  Changed my conf to match the rpcuser etc you posted. And then ran your python code exactly it hung for while, I assume 120 seconds, then it kicked out with the same error. I tried a couple more times, and now the exact same code doesnt' even wait 120 seconds, it comes back instantly now... which might be a clue what is going on but I have no idea what that might mean.

At this point I am completely lost with what I could be doing wrong.
The Journey
CC BY-SA 4.0
2024-02-04T03:29:47.257Z
I am going to completely uninstall my bitcoin core node, and start from scratch. It will take a day or two to reload the blockchain data.  I doubt it will help, but at this point I feel like I have tried everything.

Just to confirm I don't need to do anything but run bitcoin-qt.exe in the bitcoin directory to launch the node correct. Ie I don't need to be messing with the bitcoind..exe daemon exe?  I assume that the bitcoin-qt.exe is running the node?
The Journey
CC BY-SA 4.0
2024-02-04T04:06:17.670Z
Thanks again for the help.  I do appreciate it. Was hoping it would work...  I am reinstalling the node.  I am curious do I have to wait until the entire node is caught up, or can i try to connect to the node before it is up to date with the latest transactions?
The Journey
CC BY-SA 4.0
2024-02-04T10:05:56.420Z
I have added some notes to the end of my answer.
RedGrittyBrick
CC BY-SA 4.0
2024-03-17T20:45:28.490Z
By the way, thanks @RedGrittyBrick, i felt like I tried everything, i cranked up the time out to like 2000 just to be sure, it didn't help, i also tried 120, and others. Nothing seems to work. I have frankly stepped away from it for awhile now, as it is just too frustrating, nothign seems to work, and what seems easy for others, doesn't work for me... I literally tried everything I can think of, and that other people suggested about a 100 times each now.  I just needed to step away as it was unbelievable frustrating...
The Journey
CC BY-SA 4.0
2024-02-03T22:40:05.387Z
2024-02-04T10:29:16.647Z
2024-02-04T10:29:16.647Z
RedGrittyBrick
<p>I am unable to connect to my server despite trying for days.  I have asked posted questions and my .conf file and my python code and despite this no one has been able to give me a reason why it is not connecting.</p>
<p>I am able to connect to the port using telnet 127.0.0.1 [port_num]</p>
<p>And I am decently sure I have opened the ports correctly.  Nestats -a shows them open.  I have opened them both for incoming and outgoing, both for my router, and for my firewall. And when I remove the rules, I immediately get a different error stating the host refused connections.   But when i have those rules engaged I instead get the following error...</p>
<pre><code>(.venv) D:\PROJECTS\python38_env_bitcoin\src\hellobitcoin101&gt;python bitcoin104.py
&lt;bitcoinrpc.authproxy.AuthServiceProxy object at 0x0000021E5BB11730&gt;
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 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), &quot;iso-8859-1&quot;)
  File &quot;c:\users\hanso\appdata\local\programs\python\python38\lib\socket.py&quot;, line 669, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out
</code></pre>
<p>I am trying use use the user password using rpcauth.. so in my .conf file I have something like...</p>
<pre><code>rpcuser=myname
rpcauth=myname:fef852a5c3e764a3a4e7fcaa283b2f1f$eadb370e8d7705d8c960570c13b49372d1a3780aa3e1ea5013908271035d4ee9
</code></pre>
<p>I am not sure if this is the proper usage.
I got the hash using...
python ./rpcauth.py myname mypassword</p>
<p>I previous tried a setup like....</p>
<pre><code>rpcuser=myname
rpcpassword=mypassword
</code></pre>
<p>What is interesting it I also sometimes get a connection without response error as well without having changed anything...</p>
<p>For instance...</p>
<pre><code>PS D:\PROJECTS\python38_env_bitcoin\src\hellobitcoin101&gt; python .\bitcoin104.py
&gt;&gt;
&lt;bitcoinrpc.authproxy.AuthServiceProxy object at 0x000002482E142730&gt;
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
PS D:\PROJECTS\python38_env_bitcoin\src\hellobitcoin101&gt; python .\bitcoin104.py
&gt;&gt;
&lt;bitcoinrpc.authproxy.AuthServiceProxy object at 0x000001F7602E2730&gt;
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 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), &quot;iso-8859-1&quot;)
  File &quot;c:\users\hanso\appdata\local\programs\python\python38\lib\socket.py&quot;, line 669, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out
</code></pre>
<p>i have searched online and there is very little it seems in terms of examples of a properly setup .conf file and corresponding python rpc authority call...</p>
<p>Like so...</p>
<pre><code>rpc_connection = AuthServiceProxy(&quot;http://%s:%s@127.0.0.1:8334&quot;%(&quot;myname&quot;,&quot;mypassword&quot;))
best_block_hash = rpc_connection.getbestblockhash()
best_block_hash
</code></pre>
<p>It fails on the second line above, ie best_block_hash = rpc_connection.getbestblockhash()</p>
<p>At this point I think i have tried everything I can possible think of.</p>
<p>My gut is saying it is something I might be doing wrong with the user password perhaps. But I have tried many different configurations, many different passwords. Restarting the node each time and loading in the changed .conf file, and running the python script again.
And all I get is the timed out, or no response no matter what i do now..
Then if I mess with the port it I get the connection refused by host error instead.</p>
<p>If I could maybe see an example online of a properly setup .conf file with the exact rpsuser and rpcpassword text, and the same in the python rpc socket setup.  I have no idea if maybe I shouldn't be putting &quot;&quot; around something, or should be and I am not, and that has been the issue.  Or perhaps I need to be using the rpcauth in a different way...?</p>
<p>Any help would be greatly greatly appreciated...
Thanks for reading this far regardless.</p>

<bitcoin-core>
Example working bitcoin.conf file
The Journey
# Example working bitcoin.conf file

(Asked by: username_0 on 2024-02-03)

I am unable to connect to my server despite trying for days. I have asked posted questions and my .conf file and my python code and despite this no one has been able to give me a reason why it is not connecting.

I am able to connect to the port using telnet 127.0.0.1 [port\_num]

And I am decently sure I have opened the ports correctly. Nestats -a shows them open. I have opened them both for incoming and outgoing, both for my router, and for my firewall. And when I remove the rules, I immediately get a different error stating the host refused connections. But when i have those rules engaged I instead get the following error...

```
(.venv) D:\PROJECTS\python38_env_bitcoin\src\hellobitcoin101>python bitcoin104.py
<bitcoinrpc.authproxy.AuthServiceProxy object at 0x0000021E5BB11730>
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 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "c:\users\hanso\appdata\local\programs\python\python38\lib\socket.py", line 669, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

```

I am trying use use the user password using rpcauth.. so in my .conf file I have something like...

```
rpcuser=myname
rpcauth=myname:fef852a5c3e764a3a4e7fcaa283b2f1f$eadb370e8d7705d8c960570c13b49372d1a3780aa3e1ea5013908271035d4ee9

```

I am not sure if this is the proper usage.
I got the hash using...
python ./rpcauth.py myname mypassword

I previous tried a setup like....

```
rpcuser=myname
rpcpassword=mypassword

```

What is interesting it I also sometimes get a connection without response error as well without having changed anything...

For instance...

```
PS D:\PROJECTS\python38_env_bitcoin\src\hellobitcoin101> python .\bitcoin104.py
>>
<bitcoinrpc.authproxy.AuthServiceProxy object at 0x000002482E142730>
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
PS D:\PROJECTS\python38_env_bitcoin\src\hellobitcoin101> python .\bitcoin104.py
>>
<bitcoinrpc.authproxy.AuthServiceProxy object at 0x000001F7602E2730>
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 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "c:\users\hanso\appdata\local\programs\python\python38\lib\socket.py", line 669, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

```

i have searched online and there is very little it seems in terms of examples of a properly setup .conf file and corresponding python rpc authority call...

Like so...

```
rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8334"%("myname","mypassword"))
best_block_hash = rpc_connection.getbestblockhash()
best_block_hash

```

It fails on the second line above, ie best\_block\_hash = rpc\_connection.getbestblockhash()

At this point I think i have tried everything I can possible think of.

My gut is saying it is something I might be doing wrong with the user password perhaps. But I have tried many different configurations, many different passwords. Restarting the node each time and loading in the changed .conf file, and running the python script again.
And all I get is the timed out, or no response no matter what i do now..
Then if I mess with the port it I get the connection refused by host error instead.

If I could maybe see an example online of a properly setup .conf file with the exact rpsuser and rpcpassword text, and the same in the python rpc socket setup. I have no idea if maybe I shouldn't be putting "" around something, or should be and I am not, and that has been the issue. Or perhaps I need to be using the rpcauth in a different way...?

Any help would be greatly greatly appreciated...
Thanks for reading this far regardless.

**Tags:** bitcoin-core


---

## 1 answers

### Answer by username_1 on 2024-02-03. Score: 1

### Minimal bitcoin.conf

You quoted

```
  File "c:\users\hanso\appdata\local\programs\python\python38\lib\socket.py", line 669, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

```

**Pay attention to that last line**

---

With this bitcoin.conf

```
rpcuser=today
rpcpassword=temporary

```

This python script, in a file named `GetBlockCount.py`

```
from bitcoinrpc.authproxy import AuthServiceProxy

rpc_user ="today"
rpc_password="temporary"
rpc_port = "8332"

rpc_client = AuthServiceProxy("http://%s:%s@127.0.0.1:%s"%(rpc_user, rpc_password, rpc_port), timeout=120)

block_count = rpc_client.getblockcount()
print(block_count)

```

Produces this result

```
C> python GetBlockCount.py
827496

```

**Take careful note of that `timeout=120` in the script.**

---

### Notes

The above result was produced on an old and ordinary PC purchased in 2015 running Windows 10. It has an i7 processor, 8GB RAM and an ordinary HDD (not SSD).

The RPC service was provided by bitcoin-qt with RPC enabled in settings, options, main.

At the time I ran the script, Bitcoin core was about 1500 blocks behind. The script took nearly two minutes to return a result. It also produced a timeout before I increased the bitcoinrpc library default from 30 to 120.

After Bitcoin Core caught up, I find the python script returns a result in about three seconds. It is faster on subsequent invocations.

So when experiencing timeout error messages, I would either increase the timeout in the script or wait until Bitcoin core has fully synchronised.

The above is somewhat anecdotal. I wouldn't put too much weight on a single informal experiment.

---

## Related

* [Error: Unable to start HTTP server. See debug log for details](https://bitcoin.stackexchange.com/questions/118921/error-unable-to-start-http-server-see-debug-log-for-details)
* [Strange re-connection problem with python-bitcoinrpc](https://bitcoin.stackexchange.com/q/89294/13866)

> **Comments:**
> **username_0**: Thanks man. I tried this, exactly word for word.  Changed my conf to match the rpcuser etc you posted. And then ran your python code exactly it hung for while, I assume 120 seconds, then it kicked out with the same error. I tried a couple more times, and now the exact same code doesnt' even wait 120 seconds, it comes back instantly now... which might be a clue what is going on but I have no idea what that might mean.  At this point I am completely lost with what I could be doing wrong.  
> **username_0**: I am going to completely uninstall my bitcoin core node, and start from scratch. It will take a day or two to reload the blockchain data.  I doubt it will help, but at this point I feel like I have tried everything.  Just to confirm I don't need to do anything but run bitcoin-qt.exe in the bitcoin directory to launch the node correct. Ie I don't need to be messing with the bitcoind..exe daemon exe?  I assume that the bitcoin-qt.exe is running the node?  
> **username_0**: Thanks again for the help.  I do appreciate it. Was hoping it would work...  I am reinstalling the node.  I am curious do I have to wait until the entire node is caught up, or can i try to connect to the node before it is up to date with the latest transactions?  
> **username_1**: I have added some notes to the end of my answer.  
> **username_0**: By the way, thanks @username_1, i felt like I tried everything, i cranked up the time out to like 2000 just to be sure, it didn't help, i also tried 120, and others. Nothing seems to work. I have frankly stepped away from it for awhile now, as it is just too frustrating, nothign seems to work, and what seems easy for others, doesn't work for me... I literally tried everything I can think of, and that other people suggested about a 100 times each now.  I just needed to step away as it was unbelievable frustrating...  

---

