python "com.chaquo.python.PyException: ConnectionRefusedError: [Errno 111] Connection refused "

Im using Chaquopy lib and I'm trying to connect my python node to my server. The node code is inside my android app but the server code is not.

The server code:

class Block_Net:
   BlockChaine=[]
   nodes=[]
   PORT = 8000
   FORMAT = "utf-8"
   HEADER = 1024
   ADR = ("127.0.0.1", PORT)
   server=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
   server.bind(ADR)
   def __init__(self):
       print("\n Sever is Starting... \n")
       time.sleep(1)
       self.server.listen()
       print("|||- Server is listing on PORT: "+str(self.PORT)+" -|||\n")
       while True:
           connection, ADR = self.server.accept()  
           connection.send(bytes("|||- you are connected -|||\n", self.FORMAT))
           print("|||- New node :  "+"**** "+str(ADR)+" ****"+" is connected -|||\n")
           self.nodes.append(connection.recv(self.HEADER).decode(self.FORMAT))

The node code:

def start(firstName,secondeName,cardeNum):
   PORT = 8000
   FORMAT = "utf-8"
   HEADER = 1024
   ADR = ("127.0.0.1", PORT)
   node=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
   with open(join(dirname(__file__),"condidats.json"),'r') as file:
       condidats=json.load(file)
       print(condidats)
       file.close()
   print("\n ------------------ "+str(firstName)+" -------- "+str(secondeName)+" -------- "+str(cardeNum)+" ------------------ \n")
   node.connect(ADR)
   thread=threading.Thread(target=host,args=[node,FORMAT])
   thread.start()
   return str(condidats)       
def host(node,FORMAT):
   PORT2=random.randint(2000,8080)
   sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
   sock.bind((socket.gethostname(),PORT2))
   node.send(bytes(str(sock.getsockname()),FORMAT))
   
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum