title: How to solve socket.error: [Errno 10061] in Python with server and my computer
body: <p>I want to make a TCP communication between my computer and server (ubuntu).</p>
  
  <p>The server IP is 203.246.114.176 and its port 30000 is open.</p>
  
  <p>The server is running the following server.py:</p>
  
  <pre><code>import socket
  import sys
  
  # Create a TCP/IP socket
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  # Bind the socket to the port
  server_address = ('localhost', 30000)
  print &gt;&gt;sys.stderr, 'starting up on %s port %s' % server_address
  sock.bind(server_address)
  
  # Listen for incoming connections
  sock.listen(1)
  
  while True:
      # Wait for a connection
      print &gt;&gt;sys.stderr, 'waiting for a connection'
      connection, client_address = sock.accept()
  
      try:
          print &gt;&gt;sys.stderr, 'connection from', client_address
  
          # Receive the data in small chunks and retransmit it
          while True:
              data = connection.recv(16)
              print &gt;&gt;sys.stderr, 'received "%s"' % data
              if data:
                  print &gt;&gt;sys.stderr, 'sending data back to the client'
                  connection.sendall(data)
              else:
                  print &gt;&gt;sys.stderr, 'no more data from', client_address
                  break
  
      finally:
          # Clean up the connection
          connection.close()
  </code></pre>
  
  <p>And my computer has client.py:</p>
  
  <pre><code>import socket
  import sys
  
  # Create a TCP/IP socket
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  
  # Connect the socket to the port where the server is listening
  server_address = ('203.246.114.176', 30000)
  print &gt;&gt;sys.stderr, 'connecting to %s port %s' % server_address
  sock.connect(server_address)
  
  try:
  
      # Send data
      message = 'This is the message.  It will be repeated.'
      print &gt;&gt;sys.stderr, 'sending "%s"' % message
      sock.sendall(message)
  
      # Look for the response
      amount_received = 0
      amount_expected = len(message)
  
      while amount_received &lt; amount_expected:
          data = sock.recv(16)
          amount_received += len(data)
          print &gt;&gt;sys.stderr, 'received "%s"' % data
  
  finally:
      print &gt;&gt;sys.stderr, 'closing socket'
      sock.close()
  </code></pre>
  
  <p>When I run at the server, the output is like this:</p>
  
  <pre><code>starting up on localhost port 30000
  waiting for a connection
  </code></pre>
  
  <p>and the ufw status is like this:</p>
  
  <pre><code>To                         Action      From
  --                         ------      ----
  22                         ALLOW       Anywhere
  5979/tcp                   ALLOW       Anywhere
  5901                       ALLOW       Anywhere
  8080                       ALLOW       Anywhere
  5978/tcp                   ALLOW       Anywhere
  5980/tcp                   ALLOW       Anywhere
  31415                      ALLOW       Anywhere
  5981                       ALLOW       Anywhere
  5982                       ALLOW       Anywhere
  5983                       ALLOW       Anywhere
  5984                       ALLOW       Anywhere
  5985                       ALLOW       Anywhere
  22/tcp                     ALLOW       Anywhere
  2222/tcp                   ALLOW       Anywhere
  77/tcp                     ALLOW       Anywhere
  21                         ALLOW       Anywhere
  3306                       ALLOW       Anywhere
  30000/tcp                  ALLOW       Anywhere
  30001/tcp                  ALLOW       Anywhere
  30002/tcp                  ALLOW       Anywhere
  30003/tcp                  ALLOW       Anywhere
  30004/tcp                  ALLOW       Anywhere
  30005/tcp                  ALLOW       Anywhere
  30006/tcp                  ALLOW       Anywhere
  30007/tcp                  ALLOW       Anywhere
  22 (v6)                    ALLOW       Anywhere (v6)
  5979/tcp (v6)              ALLOW       Anywhere (v6)
  5901 (v6)                  ALLOW       Anywhere (v6)
  8080 (v6)                  ALLOW       Anywhere (v6)
  5978/tcp (v6)              ALLOW       Anywhere (v6)
  5980/tcp (v6)              ALLOW       Anywhere (v6)
  31415 (v6)                 ALLOW       Anywhere (v6)
  5981 (v6)                  ALLOW       Anywhere (v6)
  5982 (v6)                  ALLOW       Anywhere (v6)
  5983 (v6)                  ALLOW       Anywhere (v6)
  5984 (v6)                  ALLOW       Anywhere (v6)
  5985 (v6)                  ALLOW       Anywhere (v6)
  22/tcp (v6)                ALLOW       Anywhere (v6)
  2222/tcp (v6)              ALLOW       Anywhere (v6)
  77/tcp (v6)                ALLOW       Anywhere (v6)
  21 (v6)                    ALLOW       Anywhere (v6)
  3306 (v6)                  ALLOW       Anywhere (v6)
  30000/tcp (v6)             ALLOW       Anywhere (v6)
  30001/tcp (v6)             ALLOW       Anywhere (v6)
  30002/tcp (v6)             ALLOW       Anywhere (v6)
  30003/tcp (v6)             ALLOW       Anywhere (v6)
  30004/tcp (v6)             ALLOW       Anywhere (v6)
  30005/tcp (v6)             ALLOW       Anywhere (v6)
  30006/tcp (v6)             ALLOW       Anywhere (v6)
  30007/tcp (v6)             ALLOW       Anywhere (v6)
  </code></pre>
  
  <p>But my computer shows this output:</p>
  
  <pre><code>C:\Users\user\Documents\notepad&gt;python client.py
  Traceback (most recent call last):
    File "client.py", line 7, in &lt;module&gt;
      s.connect((host, port))
    File "C:\Python27\lib\socket.py", line 228, in meth
      return getattr(self._sock,name)(*args)
  socket.error: [Errno 10061]
  </code></pre>
  
  <p>What is the matter? And what should I do?</p>
  
  <p>help plz.</p>