title: Can't connect to Interactive Brokers with python
body: <p>I want to connect to IB with python, here is my code:</p>
  
  <pre><code>from ib.ext.Contract import Contract
  from ib.ext.Order import Order
  from ib.opt import Connection, message
  
  
  def error_handler(msg):
  
     print "Server Error: %s" % msg
  
  def reply_handler(msg):
  
     print "Server Response: %s, %s" % (msg.typeName, msg)
  
  
  
  if __name__ == "__main__":
   tws_conn = Connection.create(port=7496, clientId=100)
   tws_conn.connect()
   tws_conn.register(error_handler, 'Error')  
   tws_conn.registerAll(reply_handler)
  </code></pre>
  
  <p>Whenever I use this code I receive this error which indicates that I can't connect to server:</p>
  
  <pre><code>Server Error: &lt;error id=-1, errorCode=504, errorMsg=Not connected&gt;
  Server Response: error, &lt;error id=-1, errorCode=504, errorMsg=Not connected&gt;
  </code></pre>
  
  <p>Why I can't connect to IB?</p>