ConnectionRefusedError (Testnet)

I wish I could boot the testnet network to get algod to work. So I created this Dockerfile:

FROM algorand/testnet:latest

USER root

ENV ALGORAND_DATA /root/node/data
ENV PATH /root/node:$PATH


RUN apt-get update && apt-get install wget -y && apt-get install curl -y 
RUN cp ~/node/data/config.json.example ~/node/data/config.json \
&& sed -i '/\"Archival\"/c\\"Archival\": true,'  ~/node/data/config.json \
&& sed -i '/\"EndpointAddress\"/c\\"EndpointAddress\": \"0.0.0.0:4001\",' ~/node/data/config.json \
&& sed -i '/\"IsIndexerActive\"/c\\"IsIndexerActive\": true,' ~/node/data/config.json

WORKDIR /root/node

ADD Entrypoint.sh /Entrypoint
RUN chmod +x /Entrypoint

ENTRYPOINT ["/Entrypoint"]

and the following Entrypoint.sh:

#!/bin/bash

goal node start  
pgrep algod
goal node status -w 1000 

To start it all I use the following commands:

docker build -t test-forum .
docker run test-forum

This is what I am shown after starting the Dockerfile:


But when I try to start this simple program:

from algosdk.v2client import algod
    
my_address = "YVNCNM6TEBWTLN6OO5UYSZZNPPOH2WOJBG3S6....."

algod_address = "http://localhost:4001"
algod_token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
algod_client = algod.AlgodClient(algod_token, algod_address)
account_info = algod_client.account_info(my_address)
print("Account balance: {} microAlgos".format(account_info.get('amount')) + "\n")

I get this error:

Traceback (most recent call last):
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\urllib\request.py”, line 1348, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\http\client.py”, line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\http\client.py”, line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\http\client.py”, line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\http\client.py”, line 1037, in _send_output
self.send(msg)
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\http\client.py”, line 975, in send
self.connect()
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\http\client.py”, line 941, in connect
self.sock = self._create_connection(
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\socket.py”, line 845, in create_connection
raise err
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\socket.py”, line 833, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] Impossibile stabilire la connessione. Rifiuto persistente del computer di destinazione
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “c:\Users\loren\OneDrive\Desktop\Progetto Tirocinio\codice\client-server-invio2files\docker_sandbox\main.py”, line 8, in
account_info = algod_client.account_info(my_address)
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\site-packages\algosdk\v2client\algod.py”, line 108, in account_info
return self.algod_request(“GET”, req, **kwargs)
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\site-packages\algosdk\v2client\algod.py”, line 82, in algod_request
resp = urlopen(req)
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\urllib\request.py”, line 216, in urlopen
return opener.open(url, data, timeout)
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\urllib\request.py”, line 519, in open
response = self._open(req, data)
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\urllib\request.py”, line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\urllib\request.py”, line 496, in _call_chain
result = func(*args)
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\urllib\request.py”, line 1377, in http_open
return self.do_open(http.client.HTTPConnection, req)
File “C:\Users\loren\AppData\Local\Programs\Python\Python310\lib\urllib\request.py”, line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10061] Impossibile stabilire la connessione. Rifiuto persistente del computer di destinazione>

I would recommend using sandbox (GitHub - algorand/sandbox: Algorand node sandbox) instead of doing your own Docker.
My guess is that you need to open the 4001 port from the Docker container.

1 Like