KeyError: 'WERKZEUG_SERVER_FD' when running runserver_plus with noreload flag

Author: AutomatikCreated Sep 10, 2024Updated Mar 7, 2026

I encountered an issue when trying to run my Django server using runserver_plus with noreload flag from django-extensions in a project created via cookiecutter-django.

The command I used is: python manage.py runserver_plus 0.0.0.0:8000 --noreload

This raises the following error: KeyError: 'WERKZEUG_SERVER_FD'

Full traceback

Traceback (most recent call last):
  File "/home/path/to/my/project/manage.py", line 31, in <module>
    execute_from_command_line(sys.argv)
  File "/home/user/.venv/myvenv/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/home/user/.venv/myvenv/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/user/.venv/myvenv/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/user/.venv/myvenv/lib/python3.10/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/home/user/.venv/myvenv/lib/python3.10/site-packages/django_extensions/management/utils.py", line 62, in inner
    ret = func(self, *args, **kwargs)
  File "/home/user/.venv/myvenv/lib/python3.10/site-packages/django_extensions/management/commands/runserver_plus.py", line 338, in handle
    self.inner_run(options)
  File "/home/user/.venv/myvenv/lib/python3.10/site-packages/django_extensions/management/commands/runserver_plus.py", line 459, in inner_run
    run_simple(
  File "/home/user/.venv/myvenv/lib/python3.10/site-packages/werkzeug/serving.py", line 1075, in run_simple
    fd = int(os.environ["WERKZEUG_SERVER_FD"])
  File "/usr/lib/python3.10/os.py", line 680, in __getitem__
    raise KeyError(key) from None
KeyError: 'WERKZEUG_SERVER_FD'

And these are my requirements: base.txt

python-slugify==8.0.1  # https://github.com/un33k/python-slugify
Pillow==10.2.0  # https://github.com/python-pillow/Pillow
argon2-cffi==23.1.0  # https://github.com/hynek/argon2_cffi
# redis==5.0.1  # https://github.com/redis/redis-py
# hiredis==2.3.2  # https://github.com/redis/hiredis-py
# celery==5.3.6  # pyup: < 6.0  # https://github.com/celery/celery
# django-celery-beat==2.5.0  # https://github.com/celery/django-celery-beat
# flower==2.0.1  # https://github.com/mher/flower

# Django
# ------------------------------------------------------------------------------
django==4.2.9  # pyup: < 5.0  # https://www.djangoproject.com/
django-environ==0.11.2  # https://github.com/joke2k/django-environ
django-model-utils==4.3.1  # https://github.com/jazzband/django-model-utils
django-allauth==0.59.0  # https://github.com/pennersr/django-allauth
django-crispy-forms==2.1  # https://github.com/django-crispy-forms/django-crispy-forms
crispy-bootstrap5==2023.10  # https://github.com/django-crispy-forms/crispy-bootstrap5
django-redis==5.4.0  # https://github.com/jazzband/django-redis
# Django REST Framework
djangorestframework==3.14.0  # https://github.com/encode/django-rest-framework
django-cors-headers==4.3.1  # https://github.com/adamchainz/django-cors-headers
# DRF-spectacular for api documentation
drf-spectacular==0.27.0  # https://github.com/tfranzel/drf-spectacular
django-filter==23.5 # https://django-filter.readthedocs.io/en/latest/index.html
django-admin-rangefilter==0.12.0 # https://github.com/silentsokolov/django-admin-rangefilter
dj-rest-auth==5.0.2 # https://github.com/iMerica/dj-rest-auth

numpy==1.26.4
opencv-python-headless==4.9.0.80

local.txt

-r base.txt

Werkzeug[watchdog]==3.0.1 # https://github.com/pallets/werkzeug
ipdb==0.13.13  # https://github.com/gotcha/ipdb
psycopg[c]==3.1.16  # https://github.com/psycopg/psycopg
watchfiles==0.21.0  # https://github.com/samuelcolvin/watchfiles
toml==0.10.2 # per usare tomllib in python 3.10

# Testing
# ------------------------------------------------------------------------------
mypy==1.7.1  # https://github.com/python/mypy
django-stubs[compatible-mypy]==4.2.7  # https://github.com/typeddjango/django-stubs
pytest==7.4.4  # https://github.com/pytest-dev/pytest
pytest-sugar==0.9.7  # https://github.com/Frozenball/pytest-sugar
djangorestframework-stubs[compatible-mypy]==3.14.5  # https://github.com/typeddjango/djangorestframework-stubs

# Documentation
# ------------------------------------------------------------------------------
sphinx==7.2.6  # https://github.com/sphinx-doc/sphinx
sphinx-autobuild==2021.3.14 # https://github.com/GaretJax/sphinx-autobuild

# Code quality
# ------------------------------------------------------------------------------
flake8==7.0.0  # https://github.com/PyCQA/flake8
flake8-isort==6.1.1  # https://github.com/gforcada/flake8-isort
coverage==7.4.0  # https://github.com/nedbat/coveragepy
black==23.12.1  # https://github.com/psf/black
djlint==1.34.1  # https://github.com/Riverside-Healthcare/djLint
pylint-django==2.5.5  # https://github.com/PyCQA/pylint-django
# pylint-celery==0.3  # https://github.com/PyCQA/pylint-celery
pre-commit==3.6.0  # https://github.com/pre-commit/pre-commit

# Django
# ------------------------------------------------------------------------------
factory-boy==3.3.0  # https://github.com/FactoryBoy/factory_boy

django-debug-toolbar==4.2.0  # https://github.com/jazzband/django-debug-toolbar
django-extensions==3.2.3  # https://github.com/django-extensions/django-extensions
django-coverage-plugin==3.1.0  # https://github.com/nedbat/django_coverage_plugin
pytest-django==4.7.0  # https://github.com/pytest-dev/pytest-django

# Diagrams
# pygraphviz==1.12
pyparsing==3.1.1
pydot==2.0.0

Source: django-extensions/django-extensions