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

> IB Gateway vs TWS for day trading: memory use, daily auto restart, the weekly login, API ports and two-factor, and which one to run for your setup.

Source: https://scalpeltrade.com/blog/ib-gateway-vs-tws
By Scalpel Team. Published 2026-08-29, last changed 2026-10-15. 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](https://scalpeltrade.com/guides/glossary#tws)) 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](https://scalpeltrade.com/guides/glossary#ib-gateway)) 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](https://www.interactivebrokers.com/docs/tws-api/doc/architecture/the-trader-workstation/the-ib-gateway)). Same orders, same market data, same limits. The difference is everything around the API.

## IB Gateway vs TWS at a glance

| What | TWS | IB Gateway |
| --- | --- | --- |
| Trading screens | Full platform | None: a status window |
| Resources | Heavier | About 40% fewer, per IBKR |
| API | Off until you tick Enable ActiveX and Socket Clients | Always listening |
| Default ports | 7496 live, 7497 paper | 4001 live, 4002 paper |
| Login | Username, password, two-factor | The same |
| Daily restart | Auto restart under Lock and Exit | The same |
| Weekly login | Yes | Yes |
| Can lock on inactivity | Yes, unless Never lock is set | No |
| Manual orders and charts | Yes | No |

## 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](https://www.interactivebrokers.com/docs/tws-api/doc/tws-settings/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. 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. 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. 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. 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](https://www.interactivebrokers.com/docs/tws-api/doc/tws-settings/daily-weekly-reauthentication)). Plan to log in, with your phone to hand, before your first session of each week.

![A week from Sunday to Sunday: with Auto restart the API stays connected through nightly restarts with one two-factor login a week, while Auto log off disconnects every evening until you log in again](https://scalpeltrade.com/images/blog/ib-gateway-vs-tws/restart-week.webp)

*With Auto restart, the program restarts itself each night and you log in with two-factor once a week. Left on Auto log off, every day ends disconnected until you log in again.*

**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:

| Setting | TWS | IB Gateway |
| --- | --- | --- |
| Where | File > Global Configuration > API > Settings | Configure > Settings > API > Settings |
| Enable ActiveX and Socket Clients | Must be ticked | Not shown: always on |
| Socket port | 7496 live, 7497 paper | 4001 live, 4002 paper |
| Read-Only API | Untick to allow orders | Starts ticked: untick to allow orders |
| Allow connections from localhost only | Keep ticked | Keep ticked |
| Precautions | API > Precautions | API > Precautions |

The ports are IBKR's defaults ([IBKR's port list](https://www.interactivebrokers.com/docs/excel/dde/dde-socket-bridge/configuring-the-socket-bridge/configure-the-connecting-socket-port)). 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](https://scalpeltrade.com/guides/enable-tws-api).

![A diagram of IBKR's servers connected to TWS or IB Gateway on your computer, TWS serving the API on ports 7496 live and 7497 paper, IB Gateway on 4001 live and 4002 paper, and your app connecting at 127.0.0.1](https://scalpeltrade.com/images/blog/ib-gateway-vs-tws/connections.webp)

*Either program logs in to IBKR and serves the API on your own computer. Your app connects to 127.0.0.1 on the port that program listens on.*

## 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](https://www.interactivebrokers.com/docs/tws-api/doc/notes-limitations/supported-two-factor-authentication-2-fa) 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](https://www.interactivebrokers.com/docs/tws-api/doc/connectivity/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 setup | Run | Why |
| --- | --- | --- |
| A trading app is your only screen | IB Gateway | Lighter, never locks, nothing duplicated on screen |
| A trading app plus TWS windows | TWS with the API on | One login serves both |
| You trade by hand in TWS only | TWS, API off | No API needed |
| You want both fully open at once | TWS on one username, IB Gateway on a second | Two logins, two sets of data subscriptions |
| Older or low-memory computer | IB Gateway | About 40% fewer resources |
| New to IBKR | TWS first | Learn 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](https://scalpeltrade.com/guides/connect-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.

*Screenshot: Scalpel expects TWS, but IB Gateway is the one running. One click switches over. Demo data.*

*Screenshot: 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](https://scalpeltrade.com/guides/fix-disconnected)). 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](https://scalpeltrade.com/blog/tws-api-scalping). For the full setup from account to hotkeys, see [day trading on Interactive Brokers](https://scalpeltrade.com/blog/day-trading-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.
