IBKR login loop

Hi,

I'm a new user, and I can't get ib to stay logged in. I have an IB account with 2FA using the "Authenticator" app.

from quantrocket.ibg import set_credentials
set_credentials("ibg1", username=, trading_mode="paper")

I get a pop up box asking for password, which i enter, then i see in flightlog every 40s or so:
2025-10-13 09:04:29 quantrocket.ibg1: INFO starting ibg1
2025-10-13 09:05:10 quantrocket.ibg1: INFO starting ibg1
2025-10-13 09:05:51 quantrocket.ibg1: INFO starting ibg1

When I open the jupyter lab IB Gateway GUI, i see IB logging in, which appears successful (I see the below image), before going back to the login screen.

I tried logging into live instead, which asked for authenticator code, before appearing to login and then back to the login screen again, similar to paper

I also tried cmd line quantrocket ibg credentials ... but that did the same thing as running from python.

Are you logged into TWS on another computer? If so, that would cause IB Gateway to disconnect (as IBKR only allows one active login per username at a time). QuantRocket, seeing the disconnect, would try to start IB Gateway again.

It appears that the login process is occurring correctly but then IB Gateway is getting terminated. That points to duplicate logins as the most probable cause.

That sounds like a logical suggestion, but I don't have tws running anywhere (also verified logging into tws locally, i don't get any message about other applications logged in). Any other ideas? I've tried restarting everything etc without any success...

Do you have Flightlog terminal windows open while it happens? Anything in the detailed logs?

QuantRocket uses IBC to manage IB Gateway, and its logs might have some clues beyond what's in the detailed logs. To get the IBC logs, you can run this command from your local computer (not JupyterLab Terminal):

docker compose exec ibg1 cat /opt/IBC/ibc-log.txt

There might be a message showing that the Java process was killed. Post anything that seems interesting in the detailed logs or IBC logs. (More info is better than less.)

Looks like java is crashing - i see this line in the log:
java.lang.UnsatisfiedLinkError: /tmp/JxBrowser/7.41.3/libtoolkit.so: libgtk-3.so.0: cannot open shared object file: No such file or directory

Full log:
2025-10-13 22:33:57:304 IBC: IB username set from arguments:
2025-10-13 22:33:57:305 IBC: IB password set from arguments
2025-10-13 22:33:57:305 IBC: Trading mode set from arguments: paper
2025-10-13 22:33:57:306 IBC: Settings file is: /root/IBC/config.ini
2025-10-13 22:33:57:310 IBC: IB username set from arguments:
2025-10-13 22:33:57:310 IBC: IB password set from arguments
2025-10-13 22:33:57:310 IBC: Trading mode set from arguments: paper
2025-10-13 22:33:57:310 IBC: Version: qr3.12.4.0
System Properties

jtsConfigDir = ${installer:jtsConfigDir}
swing.boldMetal = false
java.runtime.name = Java(TM) SE Runtime Environment
sun.boot.library.path = /opt/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202/lib/amd64
java.vm.version = 25.202-b08
sun.awt.nopixfmt = true
vmOptionsPath = /root/Jts/ibgateway/1033/ibgateway.vmoptions
fullVersion = 10331d
java.vm.vendor = Oracle Corporation
java.vendor.url = http://java.oracle.com/
hideTryDemo = false
path.separator = :
java.vm.name = Java HotSpot(TM) 64-Bit Server VM
file.encoding.pkg = sun.io
sun.java.launcher = SUN_STANDARD
sun.os.patch.level = unknown
java.vm.specification.name = Java Virtual Machine Specification
user.dir = /root/Jts/ibgateway/1033
java.runtime.version = 1.8.0_202-b08
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
i4jv = 0
java.endorsed.dirs = /opt/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202/lib/endorsed
os.arch = amd64
java.io.tmpdir = /tmp
line.separator =

java.vm.specification.vendor = Oracle Corporation
os.name = Linux
sun.java2d.noddraw = true
sun.jnu.encoding = UTF-8
nightlyEnabled = true
java.library.path = /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
installDir = /root/Jts/ibgateway/1033/
java.specification.name = Java Platform API Specification
java.class.version = 52.0
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
productName = IB Gateway
mediaFileArch = linux-x64
os.version = 6.6.87.2-microsoft-standard-WSL2
user.home = /root
user.timezone = Etc/UTC
installer.uuid = e8e6d390-9bb0-475c-afdc-9105e541f304
java.awt.printerjob = sun.print.PSPrinterJob
file.encoding = UTF-8
java.specification.version = 1.8
java.class.path = /root/Jts/ibgateway/1033/.install4j/i4jruntime.jar:/root/Jts/ibgateway/1033/.install4j/launcherd958696.jar:/root/Jts/ibgateway/1033/jars/jackson-databind-2.12.3.jar:/root/Jts/ibgateway/1033/jars/fop-2.8.jar:/root/Jts/ibgateway/1033/jars/twslaunch-1033.jar:/root/Jts/ibgateway/1033/jars/jxbrowser-linux64-7.41.3.jar:/root/Jts/ibgateway/1033/jars/jackson-core-2.12.3.jar:/root/Jts/ibgateway/1033/jars/xmlgraphics-commons-2.8.jar:/root/Jts/ibgateway/1033/jars/log4j-api-2.17.1.jar:/root/Jts/ibgateway/1033/jars/jxbrowser-swing-7.41.3.jar:/root/Jts/ibgateway/1033/jars/log4j-core-2.17.1.jar:/root/Jts/ibgateway/1033/jars/twslaunch-install4j-1.12.jar:/root/Jts/ibgateway/1033/jars/commons-io-2.11.0.jar:/root/Jts/ibgateway/1033/jars/jxbrowser-7.41.3.jar:/root/Jts/ibgateway/1033/jars/batik-all-1.16.jar:/root/Jts/ibgateway/1033/jars/total-2023.jar:/root/Jts/ibgateway/1033/jars/jackson-annotations-2.12.3.jar:/root/Jts/ibgateway/1033/jars/jts4launch-1033.jar:/opt/IBC/IBC.jar
user.name = root
channel = latest
java.vm.specification.version = 1.8
sun.java.command = install4j.ibgateway.GWClient ${installer:cmdLineArgs}
java.home = /opt/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202
sun.arch.data.model = 64
user.language = en
java.specification.vendor = Oracle Corporation
awt.toolkit = sun.awt.X11.XToolkit
java.vm.info = mixed mode
privateLabel = ib
java.version = 1.8.0_202
installer.groupId =
java.ext.dirs = /opt/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202/lib/ext:/usr/java/packages/lib/ext
sun.boot.class.path = /opt/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202/lib/resources.jar:/opt/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202/lib/rt.jar:/opt/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202/lib/sunrsasign.jar:/opt/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202/lib/jsse.jar:/opt/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202/lib/jce.jar:/opt/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202/lib/charsets.jar:/opt/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202/lib/jfr.jar:/opt/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202/classes
java.vendor = Oracle Corporation
file.separator = /
twslaunch.autoupdate.serviceImpl = com.ib.tws.twslaunch.install4j.Install4jAutoUpdateService
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
install4jType = ${installer:installerType}
sun.io.unicode.encoding = UnicodeLittle
sun.cpu.endian = little
sun.locale.formatasdefault = true
installerVersion = 4.6.32
sun.cpu.isalist =

2025-10-13 22:33:57:316 IBC: Using default main window manager: null
2025-10-13 22:33:57:317 IBC: Using default config dialog manager
2025-10-13 22:33:57:322 IBC: CommandServer is starting with port 7460
2025-10-13 22:33:57:414 IBC: CommandServer listening on addresses: 172.18.0.12,0:0:0:0:0:0:0:1%lo,127.0.0.1; port: 7460
2025-10-13 22:33:57:414 IBC: CommandServer started and is ready to accept commands
2025-10-13 22:33:57:488 IBC: TWS Settings directory is: /root/Jts/ibgateway/1033
2025-10-13 22:33:57:493 IBC: Ensuring /root/Jts/ibgateway/1033/jts.ini contains required minimal lines
2025-10-13 22:33:57:493 IBC: Found setting: [Logon]/s3store=true
2025-10-13 22:33:57:494 IBC: Found setting: [Logon]/Locale=en
2025-10-13 22:33:57:494 IBC: Found setting: [Logon]/displayedproxymsg=1
2025-10-13 22:33:57:494 IBC: Found setting: [IBGateway]/ApiOnly=true
2025-10-13 22:33:57:494 IBC: Confirmed /root/Jts/ibgateway/1033/jts.ini contains required minimal lines
2025-10-13 22:33:57:499 IBC: Getting config dialog
2025-10-13 22:33:57:499 IBC: Getting config dialog
2025-10-13 22:33:57:500 IBC: Creating config dialog future
2025-10-13 22:33:57:499 IBC: Getting config dialog
2025-10-13 22:33:57:499 IBC: Getting config dialog
2025-10-13 22:33:57:499 IBC: Getting config dialog
2025-10-13 22:33:57:500 IBC: Getting config dialog
2025-10-13 22:33:57:503 IBC: Getting main window
2025-10-13 22:33:57:504 IBC: Creating main window future
2025-10-13 22:33:57:504 IBC: Waiting for config dialog future to complete
2025-10-13 22:33:57:504 IBC: Waiting for config dialog future to complete
2025-10-13 22:33:57:504 IBC: Waiting for config dialog future to complete
2025-10-13 22:33:57:505 IBC: Waiting for config dialog future to complete
2025-10-13 22:33:57:505 IBC: Waiting for config dialog future to complete
2025-10-13 22:34:01:750 IBC: Detected JFrame (ibgateway.aC) entitled: IBKR Gateway; event=Activated
2025-10-13 22:34:01:757 IBC: Detected JFrame (ibgateway.aC) entitled: IBKR Gateway; event=Opened
2025-10-13 22:34:01:759 IBC: Setting Trading mode = paper
2025-10-13 22:34:02:064 IBC: Click button: Paper Log In
2025-10-13 22:34:03:149 IBC: Detected JFrame (ibgateway.aB) entitled: Loading...; event=Activated
2025-10-13 22:34:03:151 IBC: Detected JFrame (ibgateway.aB) entitled: Loading...; event=Opened
2025-10-13 22:34:03:152 IBC: Found Gateway main window
2025-10-13 22:34:03:152 IBC: Got main window from future
2025-10-13 22:34:03:667 IBC: Detected JFrame (twslaunch.feature.welcome.D) entitled: Connecting to server (trying for another 19 seconds)...; event=Opened
2025-10-13 22:34:03:685 IBC: Detected JFrame (twslaunch.feature.welcome.D) entitled: Connecting to server (trying for another 19 seconds)...; event=Activated
LogModuleConfigurator-Init: Log4j Ver2.x found on classpath
LogModuleConfigurator-Init: LogModuleConfigurator initialized with Log4j Veri.x
2025-10-13 22:34:10:655 IBC: Detected JFrame (twslaunch.feature.welcome.D) entitled: Starting application...; event=Closed
2025-10-13 22:34:10:655 IBC: Login completed
2025-10-13 22:34:10:659 IBC: Detected JDialog (jclient.login.as) entitled: Warning; event=Opened
2025-10-13 22:34:10:660 IBC: Click button: I understand and accept
2025-10-13 22:34:11:341 IBC: Detected JDialog (jclient.login.as) entitled: Warning; event=Closed
2025-10-13 22:34:11:399 IBC: Detected JDialog (feature.configure.aj) entitled: DU9970802 Trader Workstation Configuration (Simulated Trading); event=Opened
2025-10-13 22:34:11:400 IBC: Got config dialog from future
2025-10-13 22:34:11:400 IBC: Got config dialog from future
2025-10-13 22:34:11:400 IBC: Got config dialog from future
2025-10-13 22:34:11:400 IBC: Got config dialog from future
2025-10-13 22:34:11:400 IBC: Got config dialog from future
2025-10-13 22:34:11:400 IBC: Got config dialog from future
2025-10-13 22:34:11:403 IBC: Detected JDialog (feature.configure.aj) entitled: DU9970802 Trader Workstation Configuration (Simulated Trading); event=Activated
2025-10-13 22:34:11:437 IBC: Setting 'Expose entire trading schedule to API'
2025-10-13 22:34:11:637 IBC: 'Expose entire trading schedule to API' checkbox is already set to: true
2025-10-13 22:34:11:637 IBC: Setting Send Market Data In Lots
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2025-10-13 22:34:11:638 IBC: Could not find Send Market Data In Lots checkbox
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2025-10-13 22:34:11:638 IBC: Setting Master API client ID
2025-10-13 22:34:11:639 IBC: Master API client ID is already set to 6000
2025-10-13 22:34:11:639 IBC: Setting ReadOnlyApi
2025-10-13 22:34:11:639 IBC: Read-Only API checkbox is already set to: false
2025-10-13 22:34:11:639 IBC: Setting auto-restart
2025-10-13 22:34:11:686 IBC: Auto restart radio button is already set to: true
2025-10-13 22:34:11:686 IBC: Performing port configuration
2025-10-13 22:34:11:712 IBC: TWS API socket port is already set to 4002
2025-10-13 22:34:11:714 IBC: Click button: OK
2025-10-13 22:34:11:836 IBC: Detected JDialog (feature.configure.aj) entitled: DU9970802 Trader Workstation Configuration (Simulated Trading); event=Closed
remove Client 1053
2025-10-13 22:34:14:169 IBC: Detected JDialog (jclient.browser.f) entitled: Login Messages; event=Opened
2025-10-13 22:34:14:197 IBC: Detected JDialog (jclient.browser.f) entitled: Login Messages; event=Activated
java.util.concurrent.CompletionException: java.lang.UnsatisfiedLinkError: /tmp/JxBrowser/7.41.3/libtoolkit.so: libgtk-3.so.0: cannot open shared object file: No such file or directory
at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273)
at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1592)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.UnsatisfiedLinkError: /tmp/JxBrowser/7.41.3/libtoolkit.so: libgtk-3.so.0: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at com.teamdev.jxbrowser.internal.JniLibrary.loadLibrary(JniLibrary.java:52)
at com.teamdev.jxbrowser.internal.JniLibrary.lambda$new$0(JniLibrary.java:46)
at com.teamdev.jxbrowser.internal.PrivilegedActions.lambda$doPrivileged$0(PrivilegedActions.java:36)
at java.security.AccessController.doPrivileged(Native Method)
at com.teamdev.jxbrowser.internal.PrivilegedActions.doPrivileged(PrivilegedActions.java:35)
at com.teamdev.jxbrowser.internal.JniLibrary.(JniLibrary.java:44)
at com.teamdev.jxbrowser.internal.ToolkitLibrary.(ToolkitLibrary.java:40)
at com.teamdev.jxbrowser.internal.ToolkitLibrary.instance(ToolkitLibrary.java:30)
at com.teamdev.jxbrowser.internal.xz.JniResourceExtractor.extract(JniResourceExtractor.java:47)
at com.teamdev.jxbrowser.internal.xz.XzExtractor.extract(XzExtractor.java:56)
at com.teamdev.jxbrowser.internal.OfficialDelivery.lambda$deliverTo$0(OfficialDelivery.java:43)
at com.teamdev.jxbrowser.internal.PrivilegedActions.lambda$doPrivileged$0(PrivilegedActions.java:36)
at java.security.AccessController.doPrivileged(Native Method)
at com.teamdev.jxbrowser.internal.PrivilegedActions.doPrivileged(PrivilegedActions.java:35)
at com.teamdev.jxbrowser.internal.OfficialDelivery.deliverTo(OfficialDelivery.java:40)
at com.teamdev.jxbrowser.engine.ChromiumBinaries.lambda$deliverTo$0(ChromiumBinaries.java:147)
at com.teamdev.jxbrowser.engine.ChromiumBinaries.trySynchronized(ChromiumBinaries.java:177)
at com.teamdev.jxbrowser.engine.ChromiumBinaries.deliverTo(ChromiumBinaries.java:142)
at com.teamdev.jxbrowser.engine.ChromiumBinaries.deliverTo(ChromiumBinaries.java:101)
at com.teamdev.jxbrowser.engine.internal.EngineImpl.newInstance(EngineImpl.java:150)
at com.teamdev.jxbrowser.engine.Engine.newInstance(Engine.java:163)
at feature.webapp.z.b(z.java:840)
at feature.webapp.z.a(z.java:741)
at feature.webapp.z.c(z.java:697)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
... 7 more
Exception in thread "JavaFX Application Thread" java.lang.UnsatisfiedLinkError: /opt/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202/lib/amd64/libjfxmedia.so: libasound.so.2: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at com.sun.glass.utils.NativeLibLoader.loadLibraryFullPath(NativeLibLoader.java:201)
at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:94)
at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:39)
at com.sun.media.jfxmediaimpl.NativeMediaManager.lambda$new$33(NativeMediaManager.java:115)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.media.jfxmediaimpl.NativeMediaManager.(NativeMediaManager.java:106)
at com.sun.media.jfxmediaimpl.NativeMediaManager$NativeMediaManagerInitializer.(NativeMediaManager.java:77)
at com.sun.media.jfxmediaimpl.NativeMediaManager.getDefaultInstance(NativeMediaManager.java:89)
at com.sun.media.jfxmedia.MediaManager.getSupportedContentTypes(MediaManager.java:50)
at com.sun.javafx.webkit.prism.PrismGraphicsManager.getSupportedMediaTypes(PrismGraphicsManager.java:154)
at com.sun.webkit.network.URLLoader.twkDidFinishLoading(Native Method)
at com.sun.webkit.network.URLLoader.notifyDidFinishLoading(URLLoader.java:871)
at com.sun.webkit.network.URLLoader.lambda$didFinishLoading$101(URLLoader.java:862)
at com.sun.javafx.application.PlatformImpl.lambda$null$402(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$403(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$208(GtkApplication.java:245)
at java.lang.Thread.run(Thread.java:748)

A fatal error has been detected by the Java Runtime Environment:

SIGSEGV (0xb) at pc=0x0000760632ba95da, pid=7387, tid=0x0000760468169700

JRE version: Java(TM) SE Runtime Environment (8.0_202-b08) (build 1.8.0_202-b08)

Java VM: Java HotSpot(TM) 64-Bit Server VM (25.202-b08 mixed mode linux-amd64 compressed oops)

Problematic frame:

V [libjvm.so+0x6c35da] jni_GetArrayLength+0x3a

Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

An error report file with more information is saved as:

/root/Jts/ibgateway/1033/hs_err_pid7387.log

Compiled method (c1) 21092 6399 s 3 java.io.BufferedOutputStream::flush (12 bytes)
total in heap [0x000076061569a4d0,0x000076061569acb8] = 2024
relocation [0x000076061569a5f8,0x000076061569a658] = 96
main code [0x000076061569a660,0x000076061569aaa0] = 1088
stub code [0x000076061569aaa0,0x000076061569ab58] = 184
metadata [0x000076061569ab58,0x000076061569ab70] = 24
scopes data [0x000076061569ab70,0x000076061569ac08] = 152
scopes pcs [0x000076061569ac08,0x000076061569ac98] = 144
dependencies [0x000076061569ac98,0x000076061569aca0] = 8
nul chk table [0x000076061569aca0,0x000076061569acb8] = 24

If you would like to submit a bug report, please visit:

http://bugreport.java.com/bugreport/crash.jsp

This is the same error that another user reported earlier this year when they were having identical symptoms (repeated restarts of IB Gateway). They reported resolving the issue by changing their IBKR password. They didn't provide further details so I'm not sure exactly what the issue was: was the original password too long? Did the mere act of changing the password resolve something? Did the suggestion to change it come from IBKR support?

If you are able to resolve this in the same way, please let me know if you find out any more details as to the exact nature of the issue, in case it can be handled better by QuantRocket (or at least documented).

I got it working. FYI the issue was a document submission request from IB, and the loop stopped when i submitted that