Scalpel
FeaturesCockpitPricingGuidesBlogSign inDownload
Scalpelscalpeltrade.comA keyboard-first scalping cockpit for Interactive Brokers.
ProductFeaturesCockpitPricingDownloadFAQ
ResourcesGuidesTroubleshootingGlossaryBlogCompareChangelogAccountRefer a trader
CommunityDiscordYouTube
CompanyAboutFor AI agentsContactTermsPrivacyRefundsRisk

Trading involves substantial risk of loss. Scalpel is software, not investment advice. LIVE mode places real orders in your Interactive Brokers account. No warranty. Simulated or replayed results do not guarantee future results. Scalpel is independent software and is not affiliated with, endorsed by or sponsored by Interactive Brokers LLC. IBKR and TWS are trademarks of their respective owners. Figures shown on this site are demo data, not live quotes. Scalpel is sold by QUITE RIGHT LIMITED, registered in England and Wales, company number 17053815. Copyright 2026.

    Blog/Interactive Brokers setup

    IB Gateway vs TWS for day trading: which one to run

    By Scalpel Team. October 15, 2026. 7 min read.

    In short

    IB Gateway is Trader Workstation (TWS) without the trading screens: the same login, the same API, about 40% fewer resources by IBKR's own estimate. Run IB Gateway when another program is your trading screen, and TWS when you also want IBKR's own windows for charts, manual orders or account work. Both need a two-factor login, both should be set to auto restart daily, and both make you log in again once a week.

    Every trading app that connects to Interactive Brokers through the TWS API needs one of the two programs running and logged in on your computer. The choice looks small, but it decides how much memory the setup eats, what happens at the daily restart, and whether you can still click an order in by hand when something goes wrong. Settings below were checked against IBKR's documentation on October 15, 2026.

    Scalpel is independent and not affiliated with or endorsed by Interactive Brokers.

    What IB Gateway is, and what TWS is

    TWS (glossary) is IBKR's full desktop trading platform: watchlists, charts, Level 2 in BookTrader, order entry, hotkeys, scanners, account windows. It also serves the API, once you switch the API on.

    IB Gateway (glossary) is the API server without the platform. You log in, a small status window appears, and that is all you see. IBKR's docs put it plainly: "From the perspective of an API application, IB Gateway and TWS are identical" (IBKR: The IB Gateway). Same orders, same market data, same limits. The difference is everything around the API.

    IB Gateway vs TWS at a glance

    WhatTWSIB Gateway
    Trading screensFull platformNone: a status window
    ResourcesHeavierAbout 40% fewer, per IBKR
    APIOff until you tick Enable ActiveX and Socket ClientsAlways listening
    Default ports7496 live, 7497 paper4001 live, 4002 paper
    LoginUsername, password, two-factorThe same
    Daily restartAuto restart under Lock and ExitThe same
    Weekly loginYesYes
    Can lock on inactivityYes, unless Never lock is setNo
    Manual orders and chartsYesNo

    Memory and CPU footprint

    IBKR's only published comparison is that IB Gateway "consumes about 40% fewer resources" than TWS. It does not publish megabyte figures, and real use depends on what you open: in TWS, every chart, watchlist row and depth window costs memory and CPU, while IB Gateway's load comes only from what your API programs request.

    Two things help either program:

    • Memory Allocation. Both have it under Global Configuration, General. IBKR's API docs suggest 4000 MB for API users if your computer has the room, and warn that setting it too high on a small machine causes the opposite problem (memory allocation).
    • Fewer open windows in TWS. A layout with ten charts you never look at slows the program your orders pass through.

    If your trading app already draws your charts, Level 2 and tape, running TWS underneath means paying for the same data on screen twice. That is the main reason to pick IB Gateway for day trading.

    Do not be alarmed if IB Gateway shows a yellow or inactive data farm connection when nothing is running. IBKR notes that IB Gateway does not connect to the market data farms until a program asks for data.

    Daily restart, auto log off and the weekly login

    Both programs are designed to restart once a day. Left at the default, they log you out at a set time, every API connection drops, and your trading app sits disconnected until you log in again. The fix is the same setting in each:

    1. 01

      Open Lock and Exit

      In TWS, open File > Global Configuration (Edit > Global Configuration in the Classic layout), then Lock and Exit. In IB Gateway, open Configure > Settings, then Lock and Exit.

    2. 02

      Choose Auto restart

      Select Auto restart instead of Auto log off, and set a time you never trade, such as late evening. The time is in the time zone TWS is set to, not necessarily New York time.

    3. 03

      Stop TWS from locking

      In TWS, choose Never lock Trader Workstation. A locked TWS disconnects API programs. IB Gateway does not lock on inactivity.

    4. 04

      Apply and keep the program open

      Click Apply and OK. From now on the program restarts itself each day without asking for two-factor, and API programs reconnect after it comes back.

    Auto restart does not remove the weekly login. IBKR's docs describe a session running "from Sunday to Sunday" with auto restart, after which you must enter your credentials again (daily and weekly reauthentication). Plan to log in, with your phone to hand, before your first session of each week.

    Tip

    Do not log in to Client Portal on the web with the same username while TWS or IB Gateway is running. IBKR notes that the program then cannot reconnect by itself after the next server reset. Use a second username for Client Portal if you need both.

    API settings in TWS and IB Gateway

    The API page has the same settings in both programs, in different places:

    SettingTWSIB Gateway
    WhereFile > Global Configuration > API > SettingsConfigure > Settings > API > Settings
    Enable ActiveX and Socket ClientsMust be tickedNot shown: always on
    Socket port7496 live, 7497 paper4001 live, 4002 paper
    Read-Only APIUntick to allow ordersStarts ticked: untick to allow orders
    Allow connections from localhost onlyKeep tickedKeep ticked
    PrecautionsAPI > PrecautionsAPI > Precautions

    The ports are IBKR's defaults (IBKR's port list). You can change them; the program you connect must use the same number. With Read-Only API ticked, programs can read quotes and your account but not place orders, which is a sensible lock while you only practice. Every setting is explained in enable the TWS API.

    Two-factor login and one session per username

    IBKR requires two-factor for every user, and the API programs are no exception: you approve the login in IB Key or another supported method each time you log in by hand. IBKR's two-factor page for the API lists IB Key, the smartphone apps, SMS and the Digital Security Card+ as supported, and the security code cards as not supported.

    The bigger trap is sessions. IBKR allows one trading session per username at a time (logging into multiple applications). Log in to TWS while IB Gateway runs on the same username, or to IBKR Desktop, and one of them is signed out, taking its API connections with it. You cannot run TWS and IB Gateway side by side on one username.

    If you want both, add a second username in Client Portal. Market data subscriptions are set up per username, so the second one needs its own, and pays for them.

    Why you might still want TWS open

    IB Gateway is lighter, but TWS earns its memory in a few situations:

    • A manual way out. If your trading app crashes or loses its connection while you hold a position, TWS is already open with the position in front of you. With IB Gateway, you would open TWS or the IBKR mobile app, and logging in to TWS on the same username signs IB Gateway out.
    • Charts and tools your app does not have. Option chains, Risk Navigator, the fundamentals windows and IBKR's own charts.
    • Account work. Transfers, market data subscriptions and settings are easier in TWS than in a status window.
    • Checking your app. IBKR's own advice to API users is to learn TWS first: if an order or quote looks wrong in your app, TWS shows what the broker sees.

    Which to run: TWS or IB Gateway

    Your setupRunWhy
    A trading app is your only screenIB GatewayLighter, never locks, nothing duplicated on screen
    A trading app plus TWS windowsTWS with the API onOne login serves both
    You trade by hand in TWS onlyTWS, API offNo API needed
    You want both fully open at onceTWS on one username, IB Gateway on a secondTwo logins, two sets of data subscriptions
    Older or low-memory computerIB GatewayAbout 40% fewer resources
    New to IBKRTWS firstLearn what the broker sees before you automate around it

    Where Scalpel fits

    Scalpel works with either. It connects to the API socket on the same computer at 127.0.0.1, starts on port 7497, and you set Settings > Connection > Port to whatever your program listens on: 7497 or 7496 for TWS, 4001 or 4002 for IB Gateway (connect Scalpel to Interactive Brokers).

    While the link is down, Scalpel checks every 5 seconds which program answers on those four ports and says so in a banner: Use port 7496 when TWS is on its other port, Use IB Gateway when the other program is the one running, and Start TWS or Start IB Gateway when nothing is running and the program is installed in its usual place.

    TWS is not answering on port 7497, but IB Gateway is running on port 4001.Use IB Gateway
    IBKRConnectingv1.12.6 (a1b2c3d)
    Scalpel expects TWS, but IB Gateway is the one running. One click switches over. Demo data.
    Settings
    ConnectionTradingStopsRiskSizingAppearanceAudioHotkeysIntelAbout
    IBKR TWS (stocks: market data + orders)Enabled
    Host127.0.0.1Port4001
    Scalpel starts on 7497 for TWS and 4001 for IB Gateway. Host/port changes reconnect on Apply (no restart). Disabling parks the connection so it stops retrying when nothing is running. While the link is down, a banner under the header says which program is up (TWS on 7497 or 7496, IB Gateway on 4001 or 4002) and offers to switch to it or start one.
    IBKR scanner (market scans over TWS)Enabled
    CancelApply
    Settings, Connection: Host stays 127.0.0.1, and Port matches the socket port of TWS or IB Gateway. Demo data.

    If Scalpel is your only trading screen, IB Gateway is the lighter choice. Keep in mind that Scalpel's stops are watched by the app, so if TWS or IB Gateway restarts or drops while you hold a LIVE position, nothing protects it until the link is back (fix a disconnected Scalpel). That is one more reason to set the daily restart well outside your trading hours.

    For what the API itself can and cannot do for a scalper, from market data lines to pacing, read scalping through the TWS API. For the full setup from account to hotkeys, see day trading on Interactive Brokers.

    Trading carries a significant risk of loss. Nothing here is financial advice.

    Questions

    What is IB Gateway?
    IB Gateway is Interactive Brokers' API server without the trading screens. You log in to it like TWS, and trading programs connect to it through the TWS API. It uses about 40% fewer resources than TWS, according to IBKR.
    Is IB Gateway better than TWS for day trading?
    It is better when another program is your trading screen, because it is lighter and never locks on inactivity. TWS is better if you also trade by hand or want IBKR's own charts and windows.
    What port does IB Gateway use?
    4001 for a live login and 4002 for a paper login, by default. TWS uses 7496 for live and 7497 for paper. You can change either under the API settings.
    Can I run TWS and IB Gateway at the same time?
    Not on the same username: IBKR allows one trading session per username, so logging in to one signs the other out. With a second username, which needs its own market data subscriptions, you can run both.
    Does IB Gateway need two-factor authentication?
    Yes. Every manual login needs two-factor approval, as with TWS. With Auto restart set, the daily restarts do not ask again, but you still log in once a week.
    Why does IB Gateway log out every day?
    Both IB Gateway and TWS are designed to restart daily. Set Auto restart instead of Auto log off under Lock and Exit, and it restarts itself and keeps you logged in through the week.

    Related guides

    Guide 1.4Connect Scalpel to Interactive BrokersRun TWS or IB Gateway, match the API port and watch Scalpel connect. Which program to use, the ports (7497, 7496, 4001) and what the link banner tells you.Guide 1.5Enable the API in TWS and IB GatewayTurn on Enable ActiveX and Socket Clients in TWS or IB Gateway, set the socket port, allow 127.0.0.1 and switch off read-only API so Scalpel can trade.Guide 13.1Scalpel says Disconnected: fix the IBKR connectionScalpel cannot reach TWS or IB Gateway? Check the program is running and logged in, the API is on and the port matches, and use the banner's fix.

    Keep reading

    • Day trading on Interactive Brokers: the complete setup (2026)Interactive Brokers day trading, set up end to end: 2026 margin rules, Level 2 data costs, TWS vs IB Gateway, hotkeys, Tiered vs Fixed and a checklist.
    • Scalping on Interactive Brokers: can you, and how to set it upInteractive Brokers scalping works: routing and fills are fine, TWS is the friction. A step by step TWS scalping setup, and where a cockpit saves steps.
    • A TWS day trading layout for scalpers: the Mosaic setupA TWS day trading setup step by step: Mosaic windows, color-linked groups, 1 and 5-minute charts, time and sales, saving the layout and settings for speed.
    Practice in SIM, against the live book.A lifetime license, every update included, with a 7-day refund guarantee.Ask in DiscordGet Scalpel
    Sign in