ConnectionRefusedError: [Errno 111] XML-RPC python

0

I am trying to connect to a server using python 3 with xml-rpc, but an error is appearing every time I try to connect: ConnectionRefusedError: [Errno 111] Connection refused

This is my server code: (NOTE: I'm just doing silly tests.)

from xmlrpc.server import SimpleXMLRPCServer

def void():
  x = 1000
  i = 0
  while i < x:
      i = i+1
  return True

def main():
  print("This is a server!")
  server = SimpleXMLRPCServer(("localhost", 8080))
  server.register_function(void)
  server.serve_forever()

if __name__ == "__main__":
  main()

This is my client code:

import xmlrpc.client
import time

def main():
  print("This is a client!")
  client = xmlrpc.client.ServerProxy("http://localhost:8000")
  client.void()

if __name__ == "__main__":
  start = time.time()
  main()
  total_time = ("--- %s seconds ---" % (time.time() - start))
  print("Time: " + str(total_time))
When I run xml-rpc on the same computer (different terminal) it works fine, but when I try on two different computers, it gives this error.

    
asked by anonymous 10.06.2018 / 05:11

1 answer

0

You're getting the error:

  

ConnectionRefusedError: [Errno 111] Connection refused

Because it is trying to access a Interface Loopback , the loopback interface is a virtual network interface used basically for two purposes:

  • Diagnostics;
  • For developing and testing systems that require a network interface with an IP (Webservers, etc.).

To access your local network, you need to find the local IP address of your server, doing

10.06.2018 / 06:39