Proposal: Borrow warning from Werkzeug for runserver.

I typically use runserver_plus in development from django-extensions. As a result I am used to seeing the following warning in red when starting the server:

WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.

After doing some research it turns out this warning comes from Werkzeug instead of runserver_plus directly.

I would like to suggest that a similar warning gets added to runserver directly to make explicitly clear that runserver is not intended production deployments.

My initial suggestion for the warning would be very similar, with the addition on a link to the docs like so:

WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.

For more information on production servers see the documentation:

I’ve seen several projects deployed with runserver so I’d welcome this change.

A lot of developers do not read the docs and aren’t aware of this. A lot of ops team are tasked to deploy various technologies and won’t know the intricacies of each.

It’s even worse than that. Just about every “high search result” for “deploy django docker” blogs and tutorials use runserver within the container. So there are a lot of recommendations out there suggesting this is actually a good practice.

+1, but let’s limit the warning to when DEBUG is False. That way, we won’t need to bother users who are using runserver correctly.

1 Like

I’m really on the fence about that. I understand the basic sentiment - and don’t necessarily disagree. But I think it’s also an issue that a person planning to deploy a Django project for the first time isn’t directly confronted with this.

It seems to me that it would allow the new / first time user to go quite far before seeing it. You may have someone who feels like they’re ready to deploy their code and now they’re just finding out that what they’re planning to do isn’t appropriate.

While the runserver docs make it explicit that you’re not supposed to use Django in production, the deployment docs don’t. Those docs (How to deploy Django | Django documentation | Django, Deployment checklist | Django documentation | Django) address what you can do, but other than the DEBUG setting, don’t address things you should not do. (e.g., they document how you can deploy using gunicorn, uWSGI, or mod_wsgi, but don’t explicitly tell you to avoid using runserver.)

Also, consider when someone is doing a docker deployment as perhaps the first / only time running with DEBUG=False, are they even going to see that message?

I have similar thoughts as Ken.

Instead of limiting the warning when DEBUG is False, maybe we could have a flag or environment variable for runserver with a name that would stand out to anyone seeing it in a Dockerfile. Something like --hide-unsuitable-for-production.

Thanks all!

Created a ticket here to encapsulate all of the comments above.