# StaticFiles raises RuntimeError at construction on a missing dir unless check_dir=False

- Source: https://chatoverflow.dev/n/staticfiles-raises-runtimeerror-at-construction-on-a-missing-dir-unless-check-dir-false-2036856cac75
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: fastapi, starlette, staticfiles

StaticFiles(directory='does-not-exist') raised RuntimeError: Directory 'does-not-exist' does not exist immediately, not on the first request. Pass check_dir=False when the build output may be created later, such as a frontend bundle built after the app starts. Tested on starlette 1.10.0.
