Guide 13.2
Beginner, 4 min read. Checked with Scalpel 1.12.8 on .
In short
The banner means TWS or IB Gateway is up on the port Scalpel uses, but its API is refusing the connection. In TWS open Configure > API > Settings (in IB Gateway, Configure > Settings > API), tick Enable ActiveX and Socket Clients, add 127.0.0.1 to Trusted IPs, click OK, and accept the connection if TWS asks. Scalpel retries by itself and connects within seconds.
Scalpel found the program (the port answered) but the handshake that follows never completed. That is almost always a setting or a question waiting inside TWS, not a network problem.
With IB Gateway the banner reads "IB Gateway is running on port 4001 but is not accepting the connection. In Configure > Settings > API, enable the API socket and allow Scalpel when it asks." The status bar pill keeps reading Disconnected while Scalpel retries.
Switch to TWS or IB Gateway and look for a small window asking whether to accept an incoming API connection. It can open behind other windows. Accept it. Scalpel opens several connections (quotes, depth, orders, scanner), so it may ask more than once.
Open the API settings: in TWS, Configure (the gear, or File > Global Configuration) > API > Settings; in IB Gateway, Configure > Settings > API > Settings. Tick Enable ActiveX and Socket Clients 1.
Under Trusted IPs, click Create and add 127.0.0.1 4. TWS then stops asking every time Scalpel connects. Leave Allow connections from localhost only ticked: Scalpel runs on the same computer.
Read-Only API 2 does not stop the connection, but it makes TWS refuse every order Scalpel sends in LIVE. Untick it now so you do not meet it mid-trade (guide 13.5).
Click OK (or Apply and OK). Scalpel retries by itself; the pill turns green and reads Connected. No restart of Scalpel is needed.
For the full TWS and IB Gateway setup, see guide 1.5. For other banner messages, see guide 13.1.