collectstatic now requires a redis server running #3206

Closed
opened 2025-12-29 18:26:43 +01:00 by adam · 6 comments
Owner

Originally created by @henyxia on GitHub (Jan 22, 2020).

Environment

  • Python version: 3.7.6
  • NetBox version: 2.7.1

Steps to Reproduce

  1. Just run python3 manage.py collectstatic --no-input

Expected Behavior

Previously (at least with 2.6.5), this commands generated all static files needed.

Observed Behavior

With the latest version available in container (aka 2.7.1), the script tries to establish a connection with the redis server. As we try to use this command during a containter build, the given redis server is not accessible, making the build impossible.

Here is the stack error given with this command:

python3 manage.py collectstatic --no-input
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 539, in connect
    sock = self._connect()
  File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 596, in _connect
    raise err
  File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 584, in _connect
    sock.connect(socket_address)
OSError: [Errno 99] Address not available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/netbox/extras/apps.py", line 23, in ready
    rs.ping()
  File "/usr/local/lib/python3.7/site-packages/redis/client.py", line 1106, in ping
    return self.execute_command('PING')
  File "/usr/local/lib/python3.7/site-packages/redis/client.py", line 836, in execute_command
    conn = self.connection or pool.get_connection(command_name, **options)
  File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 1073, in get_connection
    connection.connect()
  File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 544, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 99 connecting to localhost:6379. Address not available.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute
    django.setup()
  File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/opt/netbox/netbox/extras/apps.py", line 26, in ready
    "Unable to connect to the Redis database. Check that the Redis configuration has been defined in "
django.core.exceptions.ImproperlyConfigured: Unable to connect to the Redis database. Check that the Redis configuration has been defined in configuration.py.
Originally created by @henyxia on GitHub (Jan 22, 2020). <!-- NOTE: This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.7.6 * NetBox version: 2.7.1 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox (or the current beta release where applicable). Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a wrapper like pynetbox. --> ### Steps to Reproduce 1. Just run `python3 manage.py collectstatic --no-input` <!-- What did you expect to happen? --> ### Expected Behavior Previously (at least with 2.6.5), this commands generated all static files needed. <!-- What happened instead? --> ### Observed Behavior With the latest version available in container (aka 2.7.1), the script tries to establish a connection with the redis server. As we try to use this command during a containter build, the given redis server is not accessible, making the build impossible. Here is the stack error given with this command: ``` python3 manage.py collectstatic --no-input Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 539, in connect sock = self._connect() File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 596, in _connect raise err File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 584, in _connect sock.connect(socket_address) OSError: [Errno 99] Address not available During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/netbox/extras/apps.py", line 23, in ready rs.ping() File "/usr/local/lib/python3.7/site-packages/redis/client.py", line 1106, in ping return self.execute_command('PING') File "/usr/local/lib/python3.7/site-packages/redis/client.py", line 836, in execute_command conn = self.connection or pool.get_connection(command_name, **options) File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 1073, in get_connection connection.connect() File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 544, in connect raise ConnectionError(self._error_message(e)) redis.exceptions.ConnectionError: Error 99 connecting to localhost:6379. Address not available. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute django.setup() File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 122, in populate app_config.ready() File "/opt/netbox/netbox/extras/apps.py", line 26, in ready "Unable to connect to the Redis database. Check that the Redis configuration has been defined in " django.core.exceptions.ImproperlyConfigured: Unable to connect to the Redis database. Check that the Redis configuration has been defined in configuration.py. ```
adam closed this issue 2025-12-29 18:26:43 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jan 22, 2020):

NetBox v2.6 and above requires a running Redis service, as stated in the release notes. You should not assume that any part of NetBox will function without the stated requirements having been met. You'll just need to start the Redis server prior to running the collectstatic command.

@jeremystretch commented on GitHub (Jan 22, 2020): NetBox v2.6 and above requires a running Redis service, as stated in the [release notes](https://netbox.readthedocs.io/en/stable/release-notes/version-2.6/#new-dependency-redis). You should not assume that any part of NetBox will function without the stated requirements having been met. You'll just need to start the Redis server prior to running the `collectstatic` command.
Author
Owner

@henyxia commented on GitHub (Jan 22, 2020):

I do understand the need of Redis for the application to work.
But requiring a Redis server for all commands, including the one needed during build, seems a little bit overkill don't you think?

@henyxia commented on GitHub (Jan 22, 2020): I do understand the need of Redis for the application to work. But requiring a Redis server for all commands, including the one needed during build, seems a little bit overkill don't you think?
Author
Owner

@jerrykan commented on GitHub (Feb 7, 2020):

I've just hit this problem as well. I'm trying to build a docker image containing netbox and am running into problems when trying to run collectstatic because it is trying to connect to a redis server.

Is a redis server actually used by collectstatic? If not, it should be possible to run collectstatic as part of a build system without needing to make a connection to redis. I believe this is a genuine bug and should probably be re-opened.

@jerrykan commented on GitHub (Feb 7, 2020): I've just hit this problem as well. I'm trying to build a docker image containing netbox and am running into problems when trying to run `collectstatic` because it is trying to connect to a redis server. Is a redis server actually used by `collectstatic`? If not, it should be possible to run `collectstatic` as part of a build system without needing to make a connection to redis. I believe this is a genuine bug and should probably be re-opened.
Author
Owner

@fatbasstard commented on GitHub (Feb 13, 2020):

Hitting the same issue, build a docker image and need to run collectstatic, at this point there is no Redis (Redis is available when Netbox is actually running).

On 2.6.6, this was possible, when trying to upgrade to 2.7.4 we're running into the same issue, meaning we cannot upgrade now

@fatbasstard commented on GitHub (Feb 13, 2020): Hitting the same issue, build a docker image and need to run `collectstatic`, at this point there is no Redis (Redis is available when Netbox is actually running). On 2.6.6, this was possible, when trying to upgrade to 2.7.4 we're running into the same issue, meaning we cannot upgrade now
Author
Owner

@fatbasstard commented on GitHub (Feb 13, 2020):

Requirement did slightly change (https://github.com/netbox-community/netbox/pull/3936)

It used to check for Redis based on the "WEBHOOKS" configuration, now it always connects to Redis (even though it's probably not needed for the collectstatic)

@fatbasstard commented on GitHub (Feb 13, 2020): Requirement did slightly change (https://github.com/netbox-community/netbox/pull/3936) It used to check for Redis based on the "WEBHOOKS" configuration, now it always connects to Redis (even though it's probably not needed for the `collectstatic`)
Author
Owner

@DanSheps commented on GitHub (Feb 13, 2020):

Thank you for your interest in NetBox. GitHub issues are intended for reporting reproducible bugs and requesting features, and must be submitted using one of the templates provided here. For general discussion, questions, or assistance with installation issues, please post to our mailing list instead.

@DanSheps commented on GitHub (Feb 13, 2020): Thank you for your interest in NetBox. GitHub issues are intended for reporting reproducible bugs and requesting features, and must be submitted using one of the templates provided [here](https://github.com/digitalocean/netbox/issues/new/choose). For general discussion, questions, or assistance with installation issues, please post to our [mailing list](https://groups.google.com/forum/#!forum/netbox-discuss) instead.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3206