title: Heroku: ErrorTimeout connecting to a socket
body: <p>I'm having problems with a simple socket connection to an Heroku app.</p>
  <p>This is my server:</p>
  <pre><code>import socket
  import os
  import time 
  import sys
  
  server = socket.socket()
  port = int(os.environ.get(&quot;PORT&quot;, 12344))
  host = &quot;0.0.0.0&quot;
  server.bind((host, port))
  print(f&quot;###### SERVER RUNNING ON PORT {port} ({host}) ######&quot;)
  server.listen()
  
  while True:
  
      s, addr = server.accept()
      print(&quot;Recived request from:&quot;, addr)
      
      print(addr, &quot; sent: &quot;, repr(s.recv(1024)))
      
      print(&quot;Answering to:&quot;, addr)
  
      s.send(&quot;Hello, world! (from server)&quot;.encode())
      
      print(&quot;Answered to:&quot;, addr)
  
      s.close()
  </code></pre>
  <p>It builds and run perfectly on Heroku(it receives also socket connection, not from me...by at this time, I don't care much about it)</p>
  <p>This is my client:</p>
  <pre><code>import socket
  import sys
  
  HOST = 'app_name.herokuapp.com/'  # The server's hostname or IP address
  PORT = int(sys.argv[1])            # The port used by the server
  
  with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
      print(&quot;connecting to &quot; + HOST +&quot;:&quot;+str(PORT))
      s.connect((HOST, PORT))
      print(s)
      s.sendall(&quot;HI!!!&quot;.encode())
      data = s.recv(1024)
  
  print('Received', repr(data))
  </code></pre>
  <p>Running the client, after a while it returns:</p>
  <pre><code>  File &quot;./client.py&quot;, line 14, in &lt;module&gt;
      s.connect((HOST, PORT))
  TimeoutError: [Errno 110] Connection timed out
  </code></pre>
  <p>I don't know how to connect to it...am I missing something?</p>