Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on startup trying to connect to Redis #220

Closed
leon-developer-br opened this issue Jan 15, 2020 · 4 comments
Closed

Error on startup trying to connect to Redis #220

leon-developer-br opened this issue Jan 15, 2020 · 4 comments
Labels
awaiting answer There is still some open discussion.

Comments

@leon-developer-br
Copy link

Current Behavior

netox_1         | Traceback (most recent call last):
netbox_1         |   File "./manage.py", line 10, in <module>
netbox_1         |     execute_from_command_line(sys.argv)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
netbox_1         |     utility.execute()
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute
netbox_1         |     django.setup()
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
netbox_1         |     apps.populate(settings.INSTALLED_APPS)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 122, in populate
netbox_1         |     app_config.ready()
netbox_1         |   File "/opt/netbox/netbox/extras/apps.py", line 33, in ready
netbox_1         |     "Unable to connect to the Redis database. Check that the Redis configuration has been defined in "
netbox_1         | django.core.exceptions.ImproperlyConfigured: Unable to connect to the Redis database. Check that the Redis configuration has been defined in configuration.py.
netbox_1         | ⏳ Waiting on DB...
netbox_1         | Traceback (most recent call last):
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 539, in connect
netbox_1         |     sock = self._connect()
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 596, in _connect
netbox_1         |     raise err
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 584, in _connect
netbox_1         |     sock.connect(socket_address)
netbox_1         | OSError: [Errno 113] Host is unreachable
netbox_1         | 
netbox_1         | During handling of the above exception, another exception occurred:
netbox_1         | 
netbox_1         | Traceback (most recent call last):
netbox_1         |   File "/opt/netbox/netbox/extras/apps.py", line 30, in ready
netbox_1         |     rs.ping()
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/redis/client.py", line 1106, in ping
netbox_1         |     return self.execute_command('PING')
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/redis/client.py", line 836, in execute_command
netbox_1         |     conn = self.connection or pool.get_connection(command_name, **options)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 1073, in get_connection
netbox_1         |     connection.connect()
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 544, in connect
netbox_1         |     raise ConnectionError(self._error_message(e))
netbox_1         | redis.exceptions.ConnectionError: Error 113 connecting to redis:6379. Host is unreachable.
netbox_1         | 
netbox_1         | During handling of the above exception, another exception occurred:
netbox_1         | 
netbox_1         | Traceback (most recent call last):
netbox_1         |   File "./manage.py", line 10, in <module>
netbox_1         |     execute_from_command_line(sys.argv)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
netbox_1         |     utility.execute()
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute
netbox_1         |     django.setup()
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
netbox_1         |     apps.populate(settings.INSTALLED_APPS)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 122, in populate
netbox_1         |     app_config.ready()
netbox_1         |   File "/opt/netbox/netbox/extras/apps.py", line 33, in ready
netbox_1         |     "Unable to connect to the Redis database. Check that the Redis configuration has been defined in "
netbox_1         | django.core.exceptions.ImproperlyConfigured: Unable to connect to the Redis database. Check that the Redis configuration has been defined in configuration.py.
netbox_1         | ⏳ Waiting on DB...

...

Expected Behavior

Application running. Acces through browser
...

Debug Information

docker-compose version 1.25.0, build 0a186
The output of docker version: 19.03.5
The output of git rev-parse HEAD: 4e25b8a
The command you used to start the project: docker-compose up

@andre-lx
Copy link

On version 2.7.0 the REDIS section in the configuration file changed.

Old Redis configuration:

REDIS = {
    'HOST': 'localhost',
    'PORT': 6379,
    'PASSWORD': '',
    'DATABASE': 0,
    'CACHE_DATABASE': 1,
    'DEFAULT_TIMEOUT': 300,
    'SSL': False,
}

New Redis configuration:

REDIS = {
    'webhooks': {
        'HOST': 'redis.example.com',
        'PORT': 1234,
        'PASSWORD': 'foobar',
        'DATABASE': 0,
        'DEFAULT_TIMEOUT': 300,
        'SSL': False,
    },
    'caching': {
        'HOST': 'localhost',
        'PORT': 6379,
        'PASSWORD': '',
        'DATABASE': 1,
        'DEFAULT_TIMEOUT': 300,
        'SSL': False,
    }
}

So, before the build this need to be changed in the file:

/configuration/configuration.py

@cimnine
Copy link
Collaborator

cimnine commented Jan 17, 2020

See also #209

@cimnine cimnine added bug This issue describes a confirmed bug. pr There is a PR targeting this issue. labels Jan 17, 2020
@cimnine cimnine added this to the 0.21.0 milestone Jan 17, 2020
@cimnine cimnine removed bug This issue describes a confirmed bug. pr There is a PR targeting this issue. labels Jan 18, 2020
@cimnine cimnine removed this from the 0.21.0 milestone Jan 18, 2020
@cimnine
Copy link
Collaborator

cimnine commented Jan 18, 2020

On version 2.7.0 the REDIS section in the configuration file changed.

I don't think that this is the problem here. The error would be "REDIS section in configuration.py is missing webhooks subsection.", but I don't see that in the logs.

Can you add the output of docker inspect netboxcommunity/netbox:latest here (or in a gist and a link here), so that we know exactly which Docker Image is running on your machine?

Also, you're local repository seems to be on a weird commit (4e25b8a). Please update either to the release branch or to a specific release:

# 1: Update to a specific release of Netbox Docker
# (I've chosen 0.19.3 here, because you've opened the bug report before we released 0.20.0)
git fetch -p
git checkout 0.19.3

# 2: Get latest v2.6 image
docker pull netboxcommunity/netbox:v2.6
VERSION=v2.6 docker-compose up

@cimnine cimnine added the awaiting answer There is still some open discussion. label Jan 20, 2020
@decode13
Copy link

@andre-lx answer solved the problem.

@cimnine cimnine closed this as completed Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting answer There is still some open discussion.
Projects
None yet
Development

No branches or pull requests

4 participants