Search code examples
python-2.7connectionibpytws

IbPy can't connect to TWS through IB Gateway


I am using IB gateway to connect to tws, with the IbPy example Python 2.7 code from https://gist.github.com/valiant-falstaff/4093998b625d76ef4afe which produces the following error:

Server Error: <error id=-1, errorCode=502, errorMsg=Couldn't connect to TWS.  
Confirm that "Enable ActiveX and Socket Clients" is enabled on the TWS 
"Configure->API" menu.>
Server Response: error, <error id=-1, errorCode=502, errorMsg=Couldn't 
connect to TWS.  Confirm that "Enable ActiveX and Socket Clients" is enabled 
on the TWS "Configure->API" menu.>
Server Error: <error id=-1, errorCode=504, errorMsg=Not connected>
Server Response: error, <error id=-1, errorCode=504, errorMsg=Not connected>

However, I don't have the option to select "Enable ActiveX and Socket Clients" in the Gateway GUI which is shown in all the examples I've found. This is what the "standard" settings window looks like."Standard" settings window and this is what my settings window looks like My settings window. Anybody know how I can fix this?


Solution

  • Brian discovered the problem - The code called out a different port than the screenshot from the GUI. (answering for the sake of closure)