title: ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
body: <p>I'm trying to send messages from one point to an other, it was working for a while, then when I went back home, it doesn't work and I get this error:</p>
  
  <pre><code>line 20, in connect
      self.mySocket.connect((self.serverName, self.serverPort))
  ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
  </code></pre>
  
  <p>The code for these  are below. I even tried running it on a Mac and I got similar errors.</p>
  
  <p><strong>Client</strong></p>
  
  <pre><code>import socket
  
      serverName = "my_IP_Address"
      serverPort = 12000
  
      class User:
          mySocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  
          def __init__(self):
              self.serverName = serverName
              self.serverPort = serverPort
  
          def connect(self):
              print("Trying to connect at " + str(self.serverName) + " on port " + str(self.serverPort))
              self.mySocket.connect((self.serverName, self.serverPort))
  
          def sendMessage(self, msg):
              newS = msg.encode('utf-8')
              self.mySocket.send(newS)
              modifiedData = self.mySocket.recv(2048)
  
          def closeSocket(self):
              self.mySocket.close()
  
          def listen(self):
              self.mySocket.bind(('', self.serverPort))
              self.mySocket.listen(1)
              print("We are ready to receive data on port " + str(serverPort))
              while (1):
                  print("** attempting ** ")
                  connectionSocket, addr = self.mySocket.accept()
                  rcvMsg = connectionSocket.recv(2048)
                  newMsg = "I have received: " + rcvMsg.decode('utf-8')
                  print(newMsg)
                  newMsg = newMsg.encode('utf-8')
                  connectionSocket.send(newMsg)
                  connectionSocket.close()
  
                  if (rcvMsg.decode('utf-8') == 'done'):
                      break
              print("done listening")
  
      def main():
          userA = User()
          userA.listen()
  
      main()
  </code></pre>
  
  <p><strong>Server</strong></p>
  
  <pre><code>def main():
      userA = User()
      userA.connect()
      msg = "Hello from the lab"
      while(msg != "done"):
          userA.sendMessage(msg)
          msg = input("please type another message to send: ")
      print("done transmitting messages")
  
  
  main()
  </code></pre>
  
  <p>Any direction would be greatly appreciated!</p>