.ai/TROUBLESHOOTING.md
Common issues and solutions when working with Dash.
Cause: Exception raised inside callback function.
Solution:
app.run(debug=True)@app.callback(Output('out', 'children'), Input('in', 'value'), on_error=lambda e: f"Error: {e}")
def update(value):
...
Input..."Cause: Callback references component ID that doesn't exist in layout.
Solutions:
suppress_callback_exceptions=True:app = Dash(__name__, suppress_callback_exceptions=True)
Cause: Callback output is also its own input (directly or indirectly).
Solution: Restructure callbacks to break the cycle. Use State instead of Input where possible, or split into multiple callbacks.
Possible causes:
prevent_initial_call=True blocking first executionDebug: Add print() at callback start to verify it's being called.
Cause: Passing non-component to layout (e.g., raw dict, unsupported type).
Solution: Ensure all layout children are Dash components, strings, or numbers:
# Wrong
html.Div([{'key': 'value'}])
# Right
html.Div([html.Span('value')])
Possible causes:
id prop (required for callbacks)Debug: Check browser DevTools console for errors.
Cause: Using old import style.
Solution: Use new unified imports:
# Old (deprecated)
import dash_core_components as dcc
import dash_html_components as html
# New
from dash import dcc, html
Cause: Feature not available in installed Dash version.
Solution: Upgrade Dash:
pip install --upgrade dash
Cause: Port 8050 (or specified port) is occupied.
Solutions:
app.run(port=8051)lsof -i :8050 then kill <PID>PORT=8051 python app.pyPossible causes:
debug=False (hot reload requires debug mode)Solution:
app.run(
debug=True,
dev_tools_hot_reload=True,
extra_hot_reload_paths=['./custom_modules/']
)
Cause: Accessing Flask context outside request (e.g., in background thread).
Solution: Use flask.current_app inside callbacks, or pass data explicitly rather than using context.
Possible causes:
Debug: Check diskcache directory or Celery worker output for errors.
Cause: Process terminated unexpectedly.
Solution: Check for exceptions in the callback. Ensure psutil is installed.
Cause: set_progress not being called, or wrong output specified.
Solution: Ensure progress parameter matches an Output that exists:
@app.callback(
Output('result', 'children'),
Input('btn', 'n_clicks'),
progress=Output('progress', 'children'), # Must exist in layout
background=True,
manager=manager,
)
def compute(set_progress, n):
set_progress("Working...") # Call this
...
Cause: Using async def callback without async dependencies.
Solution:
pip install dash[async]
Cause: Conflicting event loops.
Solution: Dash automatically applies nest_asyncio in Jupyter. If issues persist:
import nest_asyncio
nest_asyncio.apply()
Possible causes:
register_page(__name__)_ or . (ignored)pages_folder pathSolution: Ensure each page file has:
from dash import register_page
register_page(__name__)
layout = ...
Cause: Path mismatch or routing issue.
Debug: Check dash.page_registry to see registered pages and their paths:
from dash import page_registry
print(list(page_registry.values()))
Cause: Options list reference didn't change (same list object).
Solution: Return new list object:
# Wrong - mutating existing list
options.append(new_option)
return options
# Right - return new list
return options + [new_option]
Possible causes:
figure in OutputSolution: Create new figure object:
return go.Figure(data=[...], layout={...}) # New object each time
Solutions:
virtualization=Truepage_size=20, page_action='native'Error: "session not created: This version of ChromeDriver only supports Chrome version X"
Solution: Update ChromeDriver to match your Chrome version:
# Check Chrome version
google-chrome --version
# Install matching chromedriver
pip install chromedriver-autoinstaller
Possible causes:
Solution: Add explicit waits with longer timeout:
dash_duo.wait_for_text_to_equal("#output", "expected", timeout=30)
Cause: Element hidden, overlapped, or not yet rendered.
Solution: Wait for element to be visible:
dash_duo.wait_for_element("#button")
element = dash_duo.find_element("#button")
element.click()
Possible causes:
npm ciSolution: Check build output, ensure npm ci was run in component directory.
Cause: Python package not installed in editable mode.
Solution:
pip install -e .
Solutions:
eager_loading=False (default) for lazy component loadingassets/ folderserve_locally=False to serve from CDNSolutions:
background=True for expensive computations@cache.memoize or similarPossible causes:
Solution: Use dcc.Store for state, set expire on background managers, avoid global mutable state.