# Jupyterlab startup delay - failed to connect

**URL:** <https://discourse.openondemand.org/t/jupyterlab-startup-delay-failed-to-connect/2986>\
**Category:** Get Help\
**Created:** [September 28, 2023, 10:27am UTC](https://discourse.openondemand.org/t/jupyterlab-startup-delay-failed-to-connect/2986 "2023-09-28T10:27:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ltalirz](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/ltalirz/32/1690_2.png) [@ltalirz](https://discourse.openondemand.org/u/ltalirz)\
**Post date:** [September 28, 2023, 10:27am UTC](https://discourse.openondemand.org/t/jupyterlab-startup-delay-failed-to-connect/2986/1 "2023-09-28T10:27:06Z")

</div>

We use a simple batch connect app to start jupyterlab inside a conda environment on a shared file system (natively on the worker node, not inside a container).

We notice that sometimes a new session becomes available to the user a few seconds _before_ the jupyterlab server is actually “ready” - if the user clicks “Connect” too quickly they can be greeted by a “Failed to connect” message.  
If they click again 2 seconds later, it works fine.

My question: How does OOD determine whether a session is “ready”?  
Can I configure an additional delay, or some other condition to be fulfilled before letting a user connect?  
What would be best practice here?

P.S. This is still on OOD 2 but happy to upgrade if this mechanism changed in OOD3.

---

<div class="post-metadata">

**Author:** ![travert](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/travert/32/3074_2.png) [@travert](https://discourse.openondemand.org/u/travert)\
**Post date:** [September 28, 2023, 5:57pm UTC](https://discourse.openondemand.org/t/jupyterlab-startup-delay-failed-to-connect/2986/2 "2023-09-28T17:57:41Z")

</div>

Hi sorry for the trouble.

For an interactive app like this, you could introduce a delay in the `after.sh` by calling something like `sleep 2` or check the port is open using `curl` before proceeding. The point is it’s the `after.sh` that you can use to do some checks for this and introduce a delay if needed.

It might be that the button is rendered before the connection file is fully written, but it’s hard to say without more data.

---

<div class="post-metadata">

**Author:** ![ltalirz](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/ltalirz/32/1690_2.png) [@ltalirz](https://discourse.openondemand.org/u/ltalirz)\
**Post date:** [September 28, 2023, 6:10pm UTC](https://discourse.openondemand.org/t/jupyterlab-startup-delay-failed-to-connect/2986/3 "2023-09-28T18:10:48Z")

</div>

Great, thanks a lot. I’ll try that right away.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/b/bae70bd0ed39a3ae769c2108155f4cb3e9da8385.png) [@system](https://discourse.openondemand.org/u/system)\
**Post date:** [March 26, 2024, 6:11pm UTC](https://discourse.openondemand.org/t/jupyterlab-startup-delay-failed-to-connect/2986/4 "2024-03-26T18:11:00Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
