title: How to fix Error 61 (Mac) and Error 10061(Windows) using Python 2.7.3
body: <p>I am currently attempting to create a basic LAN socket server, which works correctly when I use both the client and the server on the same computer. When I attempt to use the client and server on two computers (mac and windows) the connection is consistently refused on the client side. Here is the error that I got on my mac:</p>
  
  <pre><code>Traceback (most recent call last):
  File "/Users/*****/Desktop/Client V2.py", line 31, in &lt;module&gt;
  s.connect((host, port))
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py",
  line 224, in meth
  return getattr(self._sock,name)(*args)
  error: [Errno 61] Connection refused
  </code></pre>
  
  <p>On my windows I had the same error, only the number was different. I have turned off windows firewall for both incoming and outgoing connections, and I am confused as to what the actual issue is. Here is the code that I had for my ports:</p>
  
  <p><strong>Client</strong></p>
  
  <pre><code>#Get host and port info to connect
  host = 'localhost'
  port = input ("What is the PORT number?")
  </code></pre>
  
  <p>I am not sure if these lines are necessary, perhaps they are the root cause of the problem:</p>
  
  <pre><code>try:
      remote_ip = socket.gethostbyname(host)
  
  except socket.gaierror:
      #could not resolve
      print "Hostname could not be resolved. Exiting"
      sys.exit()
  </code></pre>
  
  <p>And finally, the actual code that connects. (I called the socket <code>s</code>)
      s.connect((host, port))</p>
  
  <p><strong>Server</strong></p>
  
  <pre><code>HOST = 'localhost' #Symbolic name meaning all available interfaces
  
  PORT = input ("Enter the PORT number (1 - 10,000)")
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  print "Socket Created"
  
  try:
      s.bind((HOST, PORT))
  except socket.error, msg:
      print "Bind failed. Error Code : " + str(msg[0]) + " Message " + str(msg[1])
      sys.exit()
  print "Socket Bind Complete"
  
  
  s.listen(10)
  print "Socket now listening"
  </code></pre>
  
  <p>I am certain that I have done something really silly, but can someone please tell me what my mistake is (or if this is even possible cross-os). I already posted <a href="https://stackoverflow.com/questions/14784132/general-python-socket-questions-with-several-answers">here</a>, but no one responded. I have several other questions there, and it would be great if someone could attempt to answer them. </p>