python runtime_error ai_generated true

werkzeug.routing.BuildError: Could not build url for endpoint 'external' with values ['scheme', 'host']. Did you mean 'index' instead?

ID: python/flask-url-for-external-scheme

Also available as: JSON · Markdown · 中文
80%Fix Rate
84%Confidence
0Evidence
2024-09-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

Attempting to use url_for with an endpoint that doesn't exist or with extra parameters not defined in the route.

generic

中文

尝试使用 url_for 引用不存在的端点,或提供了路由中未定义的额外参数。

Workarounds

  1. 100% success
    Define the route correctly: @app.route('/external') def external(): return 'ok', then use url_for('external')
  2. 80% success
    If external URL needed, use url_for('index', _external=True) if index exists

Dead Ends

Common approaches that don't work:

  1. 90% fail

    The endpoint still doesn't exist; _external only affects the URL scheme.

  2. 80% fail

    These are not valid parameters for route building unless defined in the route.