> ## Documentation Index
> Fetch the complete documentation index at: https://docs.domino.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Increasing the timeout for Shiny Server

When you access a published Shiny app, the app times out after 60 seconds of inactivity by default. Use one of the two methods below to increase this timeout.

## Prerequisites

Before applying the non-Pro workaround, confirm you have:

* A published Shiny app with separate UI and server files
* Access to edit and republish the app in Domino

## Method 1: Shiny Server Pro

If your team has a Shiny Server Pro license, you can configure application timeouts directly within your Domino installation. For configuration details, see the application timeouts section in the Shiny Server Pro documentation at [https://docs.posit.co/shiny-server/#application-timeouts.](https://docs.posit.co/shiny-server/#application-timeouts.)

If you have a license and need assistance setting this up, contact Domino support.

## Method 2: WebSocket keep-alive workaround (non-Pro)

This workaround sends a ping through the WebSocket every 15 seconds to keep the connection open, preventing the default 60-second inactivity timeout.

### Step 1: Add the keep-alive script to your UI file

Add the following code block to your UI file:

```
tags$head(
    HTML(
     "
     <script>
     var socket_timeout_interval
     var n = 0
     $(document).on('shiny:connected', function(event) {
     socket_timeout_interval = setInterval(function(){
     Shiny.onInputChange('count', n++)
     }, 15000)
     });
     $(document).on('shiny:disconnected', function(event) {
     clearInterval(socket_timeout_interval)
     });
     </script>
     "
    )
)
```

### Step 2: Add the output element to your UI file

Anywhere after the script added in Step 1, add the following line to the same UI file:

```
textOutput("keepAlive")
```

### Step 3: Add the render function to your server file

In your server file, add:

```
output$keepAlive <- renderText({
   req(input$count)
   paste("keep alive ", input$count)
 })
```

### Step 4: Verify the changes

Republish your Shiny app and confirm it loads without errors. To verify the new timeout is in effect, leave the app idle for longer than 60 seconds and confirm the session remains active.

## Still timing out?

If the workaround above doesn't resolve the issue, see [Shiny app shows a gray screen after some time or times out](https://support.domino.ai/support/s/article/Shiny-App-shows-a-gray-screen-after-sometime-or-timeouts-1718868032640) .


## Related topics

- [How-to guides](/knowledge-base/how-to-guides-overview.md)
- [Monitor model endpoints](/cloud/platform-capabilities/features/model-deployment/monitor-model-endpoints.md)
- [Publish a Shiny App](/cloud/platform-capabilities/features/apps/common-app-frameworks/shiny-app.md)
- [Common App Frameworks](/cloud/platform-capabilities/features/apps/common-app-frameworks/index.md)
