IndexError: list index out of range when multiple inputs for update graph

(First: the app seems to work anyway - despite the error.)
When I add slider input I get IndexError: list out of range, otherwise works fine. The error is still the same if I change slider to state.
My code looks like:

    app = dash.Dash()

app.layout = html.Div(children=[
    dcc.Interval(id='interval-component', interval=100000, n_intervals=0),

@app.callback(Output('live-update-graph', 'figure'),
              [Input('interval-component', 'n_intervals'), Input('slider', 'value')])
def update_graph(n, slider):
    # read data and draw the graph

It works without the slider input.
Complete error:

Traceback (most recent call last):
 File ".../python3.7/site-packages/flask/", line 2309, in __call__
    return self.wsgi_app(environ, start_response)
  File ".../python3.7/site-packages/flask/", line 2295, in wsgi_app
    response = self.handle_exception(e)
  File ".../python3.7/site-packages/flask/", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/.../python3.7/site-packages/flask/", line 35, in reraise
    raise value
  File ".../python3.7/site-packages/flask/", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File ".../python3.7/site-packages/flask/", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File ".../python3.7/site-packages/flask/", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File ".../python3.7/site-packages/flask/", line 35, in reraise
    raise value
  File ".../python3.7/site-packages/flask/", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File ".../python3.7/site-packages/flask/", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File ".../python3.7/site-packages/dash/", line 858, in dispatch
IndexError: list index out of range

Whatever you have here looks fine to me. Can I please see how your def update_graph(n, slider) depends on the slider input?

Actually it started working without the error after some time. Strange…
Thanks for the help anyway!

1 Like

I had similar ‘list index out of range’ issues, and this is when they occurred and how I stopped them:

When I change my dash app code (e.g. some callback header infos), and relaunch the app while a browser tab from an old app session is still open, this error can occur.

Simply making sure that all pre-existing, outdated app browser tabs are closed was enough to avoid the error.


THANK YOU!!! This was driving me nuts, but totally makes sense. Must have spent 4 hours trying to debug the issue, turns out the issue didn’t really exist. I can sleep easier now.

I created an account to say this: THANK YOU!

1 Like

I think that this is because multiple instances are trying to access the data simultaneously. In my case this happened when I created a database using sqlite3 (not meant for production) with auto refresh from dash that regularly queries the db. It works fine for one user, but not multiple, I expect better results after creating a more robust database solution.

+1 Fixed my same issue