# TWS signs out when IB Gateway starts

> Interactive Brokers allows one trading session per username, so TWS and IB Gateway sign each other out. Three ways to run Scalpel, and a second username.

Source: https://scalpeltrade.com/guides/fix-tws-signed-out
Guide 13.3, Troubleshooting. Beginner, 4 min read.
Checked with Scalpel 1.12.8 on 2026-10-15. By Scalpel Team.

**In short:**

Interactive Brokers allows one trading session per username. TWS, IB Gateway and IBKR Desktop all count, so logging in to IB Gateway signs TWS out, and the other way round. Run only one of them for Scalpel (IB Gateway alone is the lightest), run Scalpel alongside TWS, or add a second username in Client Portal so each program has its own login.

This is an Interactive Brokers rule, not a Scalpel setting, and no setting in TWS or Scalpel gets around it. The fix is to choose how you want to run.

## Why TWS signs out

A username can hold one live trading session. When a second program logs in with the same username, Interactive Brokers asks whether to take over the session and then closes the first one. TWS shows that it has been logged out; Scalpel loses its connection if it was using that program.

| Counts as a session | Does not |
|---|---|
| TWS | Client Portal (the website) |
| IB Gateway | |
| IBKR Desktop | |

The IBKR mobile app can also compete with your desktop login for market data. If quotes stop on your desktop while you use the app, log out of the app.

## What Scalpel shows

Scalpel was using the program that just lost the session, so you hear **IB connection lost**, the IBKR pill turns red, and the banner points at whatever is still running. If IB Gateway took the session, the banner offers to use it:

*Screenshot: TWS was signed out by an IB Gateway login: Scalpel offers to switch to IB Gateway. Demo data.*

Clicking **Use IB Gateway** connects Scalpel to the program that now holds the session. Your LIVE positions are picked back up from Interactive Brokers when it reconnects.

## Pick one of three setups

| Setup | How | Good for | Cost |
|---|---|---|---|
| **Scalpel instead of TWS** | Run IB Gateway only, logged in. Scalpel on 4001 (live) or 4002 (paper). | The lightest setup. Scalpel is your only trading screen. | Nothing extra |
| **Scalpel alongside TWS** | Run TWS only, with the API enabled. Scalpel on TWS's port (7496 live or 7497 paper by default). | Keeping TWS's own screens and windows open next to Scalpel. | Nothing extra |
| **Both fully open** | A second username: TWS logs in with one, IB Gateway with the other for Scalpel. | Running TWS and IB Gateway at the same time. | Market data is billed per username, so the second one needs its own subscriptions |

Both TWS and IB Gateway restart once a day and ask for a fresh login unless you set auto-restart in their settings, and both need your two-factor approval at login. IB Gateway has no trading screens, but it still needs you to log in.

## Add a second username

### 1. Open Users and Access Rights

Log in to Client Portal on the Interactive Brokers website and open **Settings** > **Users and Access Rights**.

### 2. Add a user for yourself

Add a new user with trading access to the same account, following Interactive Brokers' steps. It needs its own two-factor setup.

### 3. Subscribe its market data

Market data subscriptions belong to a username, not the account. Give the second username the subscriptions Scalpel needs: live quotes and Level 2 depth for the exchanges you trade ([guide 1.6](https://scalpeltrade.com/guides/ibkr-market-data-for-day-trading)).

### 4. Log each program in with its own username

TWS with your usual username, IB Gateway with the new one. Point Scalpel at IB Gateway's port in **Settings** > **Connection** ([guide 1.4](https://scalpeltrade.com/guides/connect-interactive-brokers)).

**Note.**

Running Scalpel on two computers? The same rule applies: each computer's TWS or IB Gateway needs its own username, or one will sign the other out.

## Questions

**Why does TWS log out when I start IB Gateway?**

Interactive Brokers allows one trading session per username, and TWS, IB Gateway and IBKR Desktop each count as one. The newer login takes the session.

**Can I run TWS and IB Gateway at the same time?**

Only with two usernames on your account, one per program. Market data is billed per username, so the second needs its own subscriptions.

**Does Scalpel need IB Gateway, or is TWS enough?**

Either works. IB Gateway is lighter. TWS lets you keep its own screens open. Point Scalpel at the port of the one you run.

**Does Client Portal sign out TWS?**

No. The Client Portal website is separate and keeps working alongside TWS or IB Gateway.
