Skip to content

[BUG] 4.2.0rc3 failure to lanch with flask run: ValueError: The name '_dash_assets' is already registered for a different blueprint. #3787

Closed

Description

@ghaarsma

We have a proper running Dash 4.1 application. Upon testing 4.2.0rc3 and starting the application with flask run we were greeted with: ValueError: The name '_dash_assets' is already registered for a different blueprint. Use 'name=' to provide a unique name.

Full stack:

(venv) PS C:\Users\user\Python\dash-site> flask run
2026-05-14 13:39:02 - INFO - Settings class: dash.config.LocalDevelopmentConfig
2026-05-14 13:39:03 - INFO - Database URI: sqlite:///C:\Users\user\Python\dash-site\instance\dwsc.sqlite3
2026-05-14 13:39:06 - CRITICAL - Uncaught exception
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\user\Python\dash-site\venv\Scripts\flask.exe\__main__.py", line 5, in <module>
    sys.exit(main())
             ~~~~^^
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\flask\cli.py", line 1131, in main
    cli.main()
    ~~~~~~~~^^
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\click\core.py", line 1435, in main
    rv = self.invoke(ctx)
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\click\core.py", line 1902, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\click\core.py", line 1298, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\click\core.py", line 853, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\click\decorators.py", line 93, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\click\core.py", line 853, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\flask\cli.py", line 979, in run_command
    raise e from None
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\flask\cli.py", line 963, in run_command
    app: WSGIApplication = info.load_app()  # pyright: ignore
                           ~~~~~~~~~~~~~^^
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\flask\cli.py", line 349, in load_app
    app = locate_app(import_name, name)
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\flask\cli.py", line 262, in locate_app
    return find_best_app(module)
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\flask\cli.py", line 72, in find_best_app
    app = app_factory()
  File "C:\Users\user\Python\dash-site\dash\__init__.py", line 180, in create_app
    dash_app.init_app(app)
    ~~~~~~~~~~~~~~~~~^^^^^
  File "C:\Users\user\Python\dash-site\dash\dash_app.py", line 505, in init_app
    app.init_app(server)
    ~~~~~~~~~~~~^^^^^^^^
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\dash\dash.py", line 734, in init_app
    self.backend.register_assets_blueprint(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        assets_blueprint_name,
        ^^^^^^^^^^^^^^^^^^^^^^
        config.routes_pathname_prefix + self.config.assets_url_path.lstrip("/"),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self.config.assets_folder,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\dash\backends\_flask.py", line 95, in register_assets_blueprint
    self.server.register_blueprint(bp)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\flask\sansio\scaffold.py", line 47, in wrapper_func
    return f(self, *args, **kwargs)
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\flask\sansio\app.py", line 595, in register_blueprint
    blueprint.register(self, options)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "C:\Users\user\Python\dash-site\venv\Lib\site-packages\flask\sansio\blueprints.py", line 310, in register
    raise ValueError(
    ...<3 lines>...
    )
ValueError: The name '_dash_assets' is already registered for a different blueprint. Use 'name=' to provide a unique name.
(venv) PS C:\Users\user\Python\dash-site>

I realize this is not a MRE. If this is needed to troubleshoot, I can invest the time to try to create one.

Activity

  1. AnnMarieW commented on May 16, 2026

    @AnnMarieW
    Collaborator

    @ghaarsma
    Thanks for reporting - a MRE would be very helpful.

    This error is likely caused by initializing Dash twice (or more) against the same Flask instance.

  2. ghaarsma commented on May 18, 2026

    @ghaarsma
    Author

    I have attached an MRE, in zip format. When running with Dash 4.1.0 all works fine

    (venv) PS C:\Users\gabe\Python\dash_test> flask run
     * Serving Flask app 'dash_test'
     * Debug mode: off
    

    Then swap to Dash 4.2.0rc3 in the pyproject.toml and run pip install .

    (venv) PS C:\Users\gabe\Python\dash_test> pip install .
    Processing .\.
      Installing build dependencies ... done
      Getting requirements to build wheel ... done
      Preparing metadata (pyproject.toml) ... done
    Collecting dash==4.2.0rc3 (from dash_test==2026.0.0)
      Using cached dash-4.2.0rc3-py3-none-any.whl.metadata (11 kB)
    Requirement already satisfied: python-dotenv in .\venv\Lib\site-packages (from dash_test==2026.0.0) (1.2.2)
    Requirement already satisfied: Flask<3.2,>=1.0.4 in .\venv\Lib\site-packages (from dash==4.2.0rc3->dash_test==2026.0.0) (3.1.3)
    Requirement already satisfied: Werkzeug<3.2 in .\venv\Lib\site-packages (from dash==4.2.0rc3->dash_test==2026.0.0) (3.1.8)
    Requirement already satisfied: plotly>=5.0.0 in .\venv\Lib\site-packages (from dash==4.2.0rc3->dash_test==2026.0.0) (6.7.0)
    Requirement already satisfied: importlib-metadata in .\venv\Lib\site-packages (from dash==4.2.0rc3->dash_test==2026.0.0) (9.0.0)
    Requirement already satisfied: typing_extensions>=4.1.1 in .\venv\Lib\site-packages (from dash==4.2.0rc3->dash_test==2026.0.0) (4.15.0)
    Requirement already satisfied: requests in .\venv\Lib\site-packages (from dash==4.2.0rc3->dash_test==2026.0.0) (2.34.2)
    Requirement already satisfied: retrying in .\venv\Lib\site-packages (from dash==4.2.0rc3->dash_test==2026.0.0) (1.4.2)
    Requirement already satisfied: nest-asyncio in .\venv\Lib\site-packages (from dash==4.2.0rc3->dash_test==2026.0.0) (1.6.0)
    Requirement already satisfied: setuptools in .\venv\Lib\site-packages (from dash==4.2.0rc3->dash_test==2026.0.0) (82.0.1)
    Collecting janus>=1.0.0 (from dash==4.2.0rc3->dash_test==2026.0.0)
      Using cached janus-2.0.0-py3-none-any.whl.metadata (5.3 kB)
    Requirement already satisfied: blinker>=1.9.0 in .\venv\Lib\site-packages (from Flask<3.2,>=1.0.4->dash==4.2.0rc3->dash_test==2026.0.0) (1.9.0)
    Requirement already satisfied: click>=8.1.3 in .\venv\Lib\site-packages (from Flask<3.2,>=1.0.4->dash==4.2.0rc3->dash_test==2026.0.0) (8.4.0)
    Requirement already satisfied: itsdangerous>=2.2.0 in .\venv\Lib\site-packages (from Flask<3.2,>=1.0.4->dash==4.2.0rc3->dash_test==2026.0.0) (2.2.0)
    Requirement already satisfied: jinja2>=3.1.2 in .\venv\Lib\site-packages (from Flask<3.2,>=1.0.4->dash==4.2.0rc3->dash_test==2026.0.0) (3.1.6)
    Requirement already satisfied: markupsafe>=2.1.1 in .\venv\Lib\site-packages (from Flask<3.2,>=1.0.4->dash==4.2.0rc3->dash_test==2026.0.0) (3.0.3)
    Requirement already satisfied: colorama in .\venv\Lib\site-packages (from click>=8.1.3->Flask<3.2,>=1.0.4->dash==4.2.0rc3->dash_test==2026.0.0) (0.4.6)
    Requirement already satisfied: narwhals>=1.15.1 in .\venv\Lib\site-packages (from plotly>=5.0.0->dash==4.2.0rc3->dash_test==2026.0.0) (2.21.2)
    Requirement already satisfied: packaging in .\venv\Lib\site-packages (from plotly>=5.0.0->dash==4.2.0rc3->dash_test==2026.0.0) (26.2)
    Requirement already satisfied: zipp>=3.20 in .\venv\Lib\site-packages (from importlib-metadata->dash==4.2.0rc3->dash_test==2026.0.0) (3.23.1)
    Requirement already satisfied: charset_normalizer<4,>=2 in .\venv\Lib\site-packages (from requests->dash==4.2.0rc3->dash_test==2026.0.0) (3.4.7)
    Requirement already satisfied: idna<4,>=2.5 in .\venv\Lib\site-packages (from requests->dash==4.2.0rc3->dash_test==2026.0.0) (3.15)
    Requirement already satisfied: urllib3<3,>=1.26 in .\venv\Lib\site-packages (from requests->dash==4.2.0rc3->dash_test==2026.0.0) (2.7.0)
    Requirement already satisfied: certifi>=2023.5.7 in .\venv\Lib\site-packages (from requests->dash==4.2.0rc3->dash_test==2026.0.0) (2026.4.22)
    Using cached dash-4.2.0rc3-py3-none-any.whl (7.4 MB)
    Using cached janus-2.0.0-py3-none-any.whl (12 kB)
    Building wheels for collected packages: dash_test
      Building wheel for dash_test (pyproject.toml) ... done
      Created wheel for dash_test: filename=dash_test-2026.0.0-py3-none-any.whl size=2048 sha256=640224ad3144b050306c474df9970ebb319b89f224d91c0851431c7d3f91b362
      Stored in directory: C:\Users\gabe\AppData\Local\Temp\pip-ephem-wheel-cache-3neq6qu9\wheels\64\d4\de\220d469b0ca12820b70175838f0c3b6e35e506993a93095880
    Successfully built dash_test
    Installing collected packages: janus, dash, dash_test
      Attempting uninstall: dash
        Found existing installation: dash 4.1.0
        Uninstalling dash-4.1.0:
          Successfully uninstalled dash-4.1.0
      Attempting uninstall: dash_test
        Found existing installation: dash_test 2026.0.0
        Uninstalling dash_test-2026.0.0:
          Successfully uninstalled dash_test-2026.0.0
    Successfully installed dash-4.2.0rc3 dash_test-2026.0.0 janus-2.0.0
    

    Then run flask run again

    (venv) PS C:\Users\gabe\Python\dash_test> flask run
    Traceback (most recent call last):
      File "<frozen runpy>", line 203, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "C:\Users\gabe\Python\dash_test\venv\Scripts\flask.exe\__main__.py", line 5, in <module>
        sys.exit(main())
                 ~~~~^^
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\flask\cli.py", line 1131, in main
        cli.main()
        ~~~~~~~~^^
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\click\core.py", line 1445, in main
        rv = self.invoke(ctx)
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\click\core.py", line 1912, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
                               ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\click\core.py", line 1308, in invoke
        return ctx.invoke(self.callback, **ctx.params)
               ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\click\core.py", line 877, in invoke
        return callback(*args, **kwargs)
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\click\decorators.py", line 93, in new_func
        return ctx.invoke(f, obj, *args, **kwargs)
               ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\click\core.py", line 877, in invoke
        return callback(*args, **kwargs)
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\flask\cli.py", line 979, in run_command
        raise e from None
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\flask\cli.py", line 963, in run_command
        app: WSGIApplication = info.load_app()  # pyright: ignore
                               ~~~~~~~~~~~~~^^
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\flask\cli.py", line 349, in load_app
        app = locate_app(import_name, name)
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\flask\cli.py", line 262, in locate_app
        return find_best_app(module)
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\flask\cli.py", line 72, in find_best_app
        app = app_factory()
      File "C:\Users\gabe\Python\dash_test\dash_test\__init__.py", line 8, in create_app
        dash_app.init_app(app)
        ~~~~~~~~~~~~~~~~~^^^^^
      File "C:\Users\gabe\Python\dash_test\dash_test\dash_app.py", line 32, in init_app
        app.init_app(server)
        ~~~~~~~~~~~~^^^^^^^^
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\dash\dash.py", line 734, in init_app
        self.backend.register_assets_blueprint(
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
            assets_blueprint_name,
            ^^^^^^^^^^^^^^^^^^^^^^
            config.routes_pathname_prefix + self.config.assets_url_path.lstrip("/"),
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            self.config.assets_folder,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\dash\backends\_flask.py", line 95, in register_assets_blueprint
        self.server.register_blueprint(bp)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\flask\sansio\scaffold.py", line 47, in wrapper_func
        return f(self, *args, **kwargs)
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\flask\sansio\app.py", line 595, in register_blueprint
        blueprint.register(self, options)
        ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
      File "C:\Users\gabe\Python\dash_test\venv\Lib\site-packages\flask\sansio\blueprints.py", line 310, in register
        raise ValueError(
        ...<3 lines>...
        )
    ValueError: The name '_dash_assets' is already registered for a different blueprint. Use 'name=' to provide a unique name.
    (venv) PS C:\Users\gabe\Python\dash_test>
    

    Note that flask run is not the only way it fails. flask --app dash_test run will also fail.

    dash_test.zip

  3. T4rk1n commented on May 19, 2026

    @T4rk1n
    Contributor

    For this pattern to work properly, you need to init dash with server=False. eg:

    app = Dash(__name__, server=False, title="Dash Test")
    

    This is the relevant docstring explaining the behavior:

    dash/dash/dash.py

    Lines 240 to 244 in d2b77b0

    :param name: The name Flask should use for your app. Even if you provide
    your own ``server``, ``name`` will be used to help find assets.
    Typically ``__name__`` (the magic global var, not a string) is the
    best value to use. Default ``'__main__'``, env: ``DASH_APP_NAME``
    :type name: string

    • True (default): Dash creates a server immediately
    • False: Server will be added later via init_app(server)

    The user's app is using the default (server=True), which already creates and initializes a Flask server, but then they're calling init_app() with a different Flask app - that's the wrong pattern.

    The fix is in the user's app - they need server=False:

    app = Dash(name, title="Dash Test", server=False)

    This worked before probably because the old code path didn't fully initialize everything in init when server=True, so calling init_app again happened to work. Now the backend refactor correctly separates the two patterns, exposing the
    incorrect usage.

    That being said, someone could put a safeguard to init_app to prevent such issues.

  4. ghaarsma commented on May 19, 2026

    @ghaarsma
    Author

    Hi @T4rk1n , Thank you for the help. I have implemented your suggested fix server=False in the Dash call in both Dash 4.1 and Dash 4.2.0rc3

    Using the MRE with Dash 4.1 and server=False everything works as it should.

    With Dash 4.2.0.rc3 and 'server=False`, the reported ValueError: The name '_dash_assets' is already registered for a different blueprint. goes away, but now the Flask/Dash server will not serve up the page. Everything is returning a 404 Not Found HTTP error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions