TWS Auto Restart: keep your trading VPS running
TWS closes every night on your trading VPS? Enable its built-in auto restart to avoid daily login, then schedule IB historical downloads after midnight.
FRTWS Auto Restart: keep your trading VPS running
You set up your trading environment on a VPS or a dedicated PC so it can keep running. Yet every morning brings the same routine: connect to the remote desktop, launch Trader Workstation again, enter your Interactive Brokers credentials and, when requested, approve the login on your phone.
The computer stayed on. Your application stayed on. TWS closed overnight, and the whole setup needs you at a screen again.
We encountered this with a scheduled shutdown at 23:50. That was the configured time on our installation, not a universal IBKR requirement. If you are searching for “TWS closes every night”, “automatic TWS restart” or “keep TWS running on a trading VPS”, check the platform’s exit timer first.
The solution may already be built in: TWS Auto Restart. It avoids manually logging back in every day, while retaining a weekly authentication requirement. IBKR’s introduction of the native feature.
Why daily TWS shutdown is frustrating on a trading VPS
An evening shutdown might be unremarkable on a workstation you open occasionally. On a dedicated computer, it undermines the point of the setup: having an environment available without restarting everything each morning.
Depending on the applications using the API, quotes stop arriving, monitoring screens become stale, recording stops or a strategy waits for a connection. Orders already sent to the broker have their own lifecycle; a TWS shutdown does not establish that they have been cancelled.
The workaround becomes another daily task: set a reminder, check the remote desktop before the market opens, or find a script to start TWS and enter a password. That script must then deal with login screens, updates and IB Key authentication.
Before adding another program to manage credentials, check the native setting. For the nightly restart, it can remove that routine without sharing your password with an extra application.
Auto Log Off and Auto Restart do different things
Under Lock and Exit, Set Auto Log Off Time ends the session at a chosen time. Set Auto Restart Time restarts the platform without daily authentication. IBKR’s description of both timer options.
Moving the shutdown time only postpones the problem. Selecting automatic restart changes what happens: TWS should return after the daily restart rather than remain closed until you log in again.
How to enable TWS Auto Restart
In TWS Mosaic:
- Open File → Global Configuration.
- Select Lock and Exit on the left.
- Find Auto Log off / Restart Timer.
- Choose Set Auto Restart Time and set the time.
- Confirm with Apply / OK.
For Classic TWS, start from Edit → Global Configuration. TWS menu instructions.
Choose a time that fits the instruments you follow. Nighttime in your location does not necessarily mean markets are closed, particularly for US futures such as YM. Check the clock and time zone on the remote installation as well.
Watch the first scheduled restart while you are available. Verify both TWS and its connected applications: an open platform window alone does not prove that quotes are flowing again.
What this means for continuous trading
Auto Restart reduces daily intervention. It does not provide an uninterrupted API connection. TWS restarts, connections can drop, and client applications must reconnect and restore their subscriptions.
An application that sends orders also needs to reconcile its state with the broker before resuming. The TWS setting cannot implement that logic for the trading software.
After updates, network outages or a VPS reboot, check the complete setup. A process monitor can report a stopped program, but you still need to verify the actual IB session and data feeds.
The practical benefit is substantial: a task imposed every morning generally becomes a weekly authentication check, alongside monitoring for incidents.
Weekly authentication and IB Key still apply
IBKR says its tokens are invalidated on Sunday at 1 am Eastern Time. The first subsequent login requires manual authentication; tokens can also be revoked exceptionally. Keep IB Key enabled and plan this intervention before your first session of the week. Auto Restart conditions.
Sleep, power loss and operating system reboots can prevent the mechanism from working. IBKR also recommends the Offline distribution of TWS to reduce interruptions related to automatic updates. IBKR operating considerations.
“Offline” means the distribution does not update automatically, not that trading works without Internet access. TWS Online and Offline versions.
An additional benefit: historical downloads after midnight
Once the platform stays available across days, the same machine can retrieve market history during quieter periods. That is an additional benefit after the trading use case.
IBDesk Collector retrieves completed sessions through your TWS or IB Gateway: trades, bid/ask quotes and five-second bars. It does not need to have recorded the entire session live. Keep the collector running and the IB platform accessible during retrieval.
To place those requests outside your trading hours, set a daily window in your account’s collection settings, using Collector 0.1.1 or later:
| Setting | Example |
|---|---|
| Start | 00:00 |
| End | 06:00 |
| Time zone | Europe/Paris |
The time zone is explicit: the window follows Paris time even when the VPS uses UTC. An overnight range such as 23:00–06:00 is supported. Times follow daylight saving changes in the selected zone.
At the end of the window, the collector stops sending new IB requests. A response already in progress can finish and be saved. Progress is retained and retrieval resumes automatically at the next window. Manually requested historical sessions follow the same schedule.
Midnight does not prove a session is closed. The collector checks the session hours supplied by IB and waits until close, with a fifteen-minute margin. Futures may close at different times from equities; retrieval then proceeds in a window where the session has actually ended.
This provides recurring post-session collection, rather than continuous live recording. Downloads can progress night after night without a daily manual start.
Download IBDesk Collector for macOS. Available packages cover Apple silicon and Intel Macs running macOS 14 or later.
Useful history can take more than one night
Trades alone do not show the spread. Keeping bid and ask data supports analyses that account for the prices offered on each side. IB provides these as separate historical streams. Historical Time & Sales streams.
The collector spaces requests and retains its request budget across restarts. A large universe can take several nights: the window schedules work, it does not accelerate IB responses or reserve exclusive API capacity. Start with one session and a small group before expanding.
Data goes to the IBDesk backend and then to ClickHouse on the service’s infrastructure, with access tied to your account. ClickHouse credentials stay in the backend. The collector does not receive your IB password, place orders, purchase subscriptions or request paid snapshots. Existing market subscriptions retain their own fees and restrictions.
Historical ticks do not reproduce the full order book, and their precision is the precision supplied by IB. Collection prepares the archives; direct loading into the existing SQLite replay engine is not integrated yet.
Frequently asked questions
How do I stop TWS from closing every night?
Check Global Configuration → Lock and Exit and select Set Auto Restart Time. The aim is for TWS to return after its daily restart. Your previous Auto Log Off time, such as 23:50, is an installation setting.
Can TWS run on a VPS without a password every morning?
Native restart supports that between required authentications. Initial login, weekly authentication and exceptional token revocations still need your attention. A complete machine reboot also requires restoring the platform session.
Should I disable two-factor authentication?
No. Keep IB Key enabled. Auto Restart does not require bypassing phone approval; logins that require approval remain manual.
Does IB Gateway support automatic restart too?
IBKR introduced the feature for both TWS and IB Gateway: daily restart with periodic manual authentication. Official release notes.
Does the collector launch TWS after a complete VPS shutdown?
It uses an existing IB session. After a complete shutdown, launch and authenticate the platform again. Auto Restart maintains the daily session; the collection window determines when historical requests may run.
IBDesk is independent software and is not affiliated with Interactive Brokers.