title: Python, Connectin Refused 10061
body: <p>I keep getting this error</p>
  
  <blockquote>
    <p>[Errno 10061] No connection could be made because the target machine actively refused it.</p>
  </blockquote>
  
  <p>I'm running Windows 7 64 bit, no virus or protection software, and python is allowed through my firewall (I've also tried turning my firewall completely off but same result). When I run the server and use telnet it connects just fine. When I try to connect to the server with the client it fails. Any suggestions as to what I could try to fix this? If you need more information just ask and I'll provide. </p>
  
  <p><strong>Client Code</strong></p>
  
  <pre><code>import socket
  import sys
  def main():
     host = ""
     port = 8934
     message = "Hello World!"
  
     host = raw_input("Enter IP: ")
     #Create Socket
     try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     except socket.error, msg:
        print "Failed to create socket. Error code: %s Error Message: %s"%(str(msg[0]),msg[1])
        sys.exit()
     print "Socket created"
  
     #Connec to Server
     print host
     print port
     s.connect((host,port))
     print "You are connected to %s with IP adress of %s"%(host,host)
  
     #Send Data
     try:
        s.sendall(message)
     except socket.error:
        print "Failed to send."
     #Receive Data
        reply = s.recv(4096)
  
  if __name__ == "__main__":
     main()
  </code></pre>
  
  <p><strong>Server Code</strong></p>
  
  <pre><code># !usr/bin/python
  
  import socket
  import sys
  
  HOST = ""
  PORT = 8934
  
  def main():
     #Setup socket
     try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     except socket.error,msg:
        print "Unable to create socket"
        sys.exit()
     print "Socket created."
  
     #Bind to adress
     try:
        s.bind((HOST,PORT))
     except socket.error,msg:
        print "Bind failed. Closing..."
        sys.exit()
     print "Socket bound."
  
     #Start listening
     s.listen(10)
     print "Socket Listening"
  
     #Accept connection
     conn, addr = s.accept()
     print "Connected to %s:%s"%(addr[0],addr[1])
  
  if __name__ == "__main__":
     main()
  </code></pre>