title: Python - socket.error: Cannot assign requested address
body: <p>I have written a chat server but I cannot bind my socket to an IP address:</p>
  
  <pre><code>import sys
  import os
  import socket
  
  HOST = "194.118.168.131"
  SOCKET_LIST = []
  RECV_BUFFER = 4096 
  PORT = 9009
  
  def chat_server():
  
      server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
      server_socket.bind((HOST, PORT))
      server_socket.listen(10)
  ...
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "server.py", line 83, in &lt;module&gt;
      sys.exit(chat_server())
    File "server.py", line 20, in chat_server
      server_socket.bind((HOST, PORT))
    File "/usr/lib/python2.7/socket.py", line 224, in meth
      return getattr(self._sock,name)(*args)
  socket.error: [Errno 99] Cannot assign requested address
  </code></pre>
  
  <p>What's wrong with my code?</p>
  
  <hr>
  
  <p>I didn't find an answer on:</p>
  
  <p><a href="https://stackoverflow.com/questions/30992881/connection-aborted-error99-cannot-assign-requested-address-error-in-pyt">&#39;Connection aborted.&#39;, error(99, &#39;Cannot assign requested address&#39;) error in Python</a>,<br>
  <a href="https://stackoverflow.com/questions/43460287/socket-errorerrno-99-cannot-assign-requested-address">socket.error[Errno 99] Cannot assign requested address</a>,<br>
  <a href="https://stackoverflow.com/questions/14471885/bind-cannot-assign-requested-address">bind: cannot assign requested address</a><br>
  <a href="https://stackoverflow.com/questions/7640619/cannot-assign-requested-address-possible-causes">Cannot assign requested address - possible causes?</a></p>