Skip to content

Djangos collectstatic fails with DEBUG=True and no Redis service running #18515

@tobiasge

Description

@tobiasge

Deployment Type

Self-hosted

NetBox Version

v4.2.2

Python Version

3.12

Steps to Reproduce

  1. Set DEBUG = True in configuration
  2. Stop any local Redis service
  3. run manage.py collectstatic (probably any other command also fails)

Expected Behavior

I expect the static files to be collected.
The reason for having DEBUG = True in the configuration is that the static files for the debug_toolbar Django app are only collected when the debug mode is on (see settings.py, line 416).

Observed Behavior

The management command fails with the error bellow. This is caused by core/apps.py, lines 30 and 31.

5.676   File "/opt/netbox/venv/lib/python3.12/site-packages/django_redis/cache.py", line 29, in _decorator
5.676     return method(self, *args, **kwargs)
5.676            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5.676   File "/opt/netbox/venv/lib/python3.12/site-packages/django_redis/cache.py", line 118, in clear
5.676     return self.client.clear()
5.676            ^^^^^^^^^^^^^^^^^^^
5.676   File "/opt/netbox/venv/lib/python3.12/site-packages/django_redis/client/default.py", line 438, in clear
5.676     raise ConnectionInterrupted(connection=client) from e
5.676 django_redis.exceptions.ConnectionInterrupted: Redis ConnectionError: Error 111 connecting to localhost:6379. Connection refused.
5.676
5.676 During handling of the above exception, another exception occurred:
5.676
5.676 Traceback (most recent call last):
5.676   File "/opt/netbox/netbox/manage.py", line 10, in <module>
5.676     execute_from_command_line(sys.argv)
5.676   File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
5.676     utility.execute()
5.676   File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 416, in execute
5.676     django.setup()
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/django/__init__.py", line 24, in setup
5.677     apps.populate(settings.INSTALLED_APPS)
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/django/apps/registry.py", line 124, in populate
5.677     app_config.ready()
5.677   File "/opt/netbox/netbox/core/apps.py", line 31, in ready
5.677     cache.clear()
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/django_redis/cache.py", line 36, in _decorator
5.677     raise e.__cause__
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/django_redis/client/default.py", line 436, in clear
5.677     client.flushdb()
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/redis/commands/core.py", line 941, in flushdb
5.677     return self.execute_command("FLUSHDB", *args, **kwargs)
5.677            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/redis/client.py", line 559, in execute_command
5.677     return self._execute_command(*args, **options)
5.677            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/redis/client.py", line 565, in _execute_command
5.677     conn = self.connection or pool.get_connection(command_name, **options)
5.677                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/redis/connection.py", line 1422, in get_connection
5.677     connection.connect()
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/redis/connection.py", line 363, in connect
5.677     raise ConnectionError(self._error_message(e))
5.677 redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection refused.

Metadata

Metadata

Assignees

Labels

severity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions