LibrePhotos / librephotos

A self-hosted open source photo management service. This is the repository of the backend.
MIT License
6.87k stars 298 forks source link

Can't connect: 504 Gateway Time-out #316

Closed mcwieger closed 3 years ago

mcwieger commented 3 years ago

I set up a brand new instance of librephotos, using docker-compose on Synology. I made some changes to the .env file (use port 3001 instead of 3000) and the process appears to go well (one warning: ssh key not set). When I try to log in to localhost:3001, I get a 504 Gateway Time-out returned.

The proxy log says the following:

2021-08-18 07:35:56 stderr  2021/08/18 07:35:56 [info] 29#29: *19 client 172.19.0.1 closed keepalive connection
2021-08-18 07:35:54 stdout  172.19.0.1 - - [18/Aug/2021:07:35:54 +0000] "GET /favicon.ico HTTP/1.1" 504 569 "http://192.168.2.201:3001/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"
2021-08-18 07:35:54 stderr  2021/08/18 07:35:54 [error] 29#29: *19 upstream timed out (110: Connection timed out) while connecting to upstream, client: 172.19.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://172.19.0.5:3000/favicon.ico", host: "192.168.2.201:3001", referrer: "http://192.168.2.201:3001/"
2021-08-18 07:34:53 stdout  172.19.0.1 - - [18/Aug/2021:07:34:53 +0000] "GET / HTTP/1.1" 504 569 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"
2021-08-18 07:34:53 stderr  2021/08/18 07:34:53 [error] 29#29: *19 upstream timed out (110: Connection timed out) while connecting to upstream, client: 172.19.0.1, server: , request: "GET / HTTP/1.1", upstream: "http://172.19.0.5:3000/", host: "192.168.2.201:3001"
2021-08-18 07:33:53 stdout  172.19.0.1 - - [18/Aug/2021:07:33:53 +0000] "GET / HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"
2021-08-18 07:33:53 stderr  2021/08/18 07:33:53 [info] 29#29: *16 epoll_wait() reported that client prematurely closed connection, so upstream connection is closed too while connecting to upstream, client: 172.19.0.1, server: , request: "GET / HTTP/1.1", upstream: "http://172.19.0.5:3000/", host: "192.168.2.201:3001"
2021-08-18 07:33:51 stderr  2021/08/18 07:33:51 [info] 29#29: *17 client closed connection while waiting for request, client: 172.19.0.1, server: 0.0.0.0:80

What can be the cause?

derneuere commented 3 years ago

This just means, that the backend does not respond. Usually you have to wait a bit until you can log in. How long did you wait?

mcwieger commented 3 years ago

I've waited for several hours, overnight even...

derneuere commented 3 years ago

The most common reason the backend isn't starting up is because the librephotos.env was not renamed to .env If that is not your error, then please look into the ownphotos.log file to look for errors. It could also be helpful to run docker-compose up without the -d to look what is happening on startup.

mcwieger commented 3 years ago

That's not the case, unfortunately (3001 is picked up as the port, it just doesn't seem to connect to it). Is there a way to run it in host environment, but with alternative ports (3000 and 80 are in use)?

derneuere commented 3 years ago

I can't reproduce the issue. Please only change the env value "httpPort".

The default only uses the 3000 port. The other ports are used internally within the docker-compose network and should not interfere with the regular host network.

mcwieger commented 3 years ago

I did a fresh install with the latest packages. Now the backend is giving issues:

backend_1   | Traceback (most recent call last):
backend_1   |   File "/code/manage.py", line 22, in <module>
backend_1   |     execute_from_command_line(sys.argv)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
backend_1   |     utility.execute()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 395, in execute
backend_1   |     self.fetch_command(subcommand).run_from_argv(self.argv)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/base.py", line 330, in run_from_argv
backend_1   |     self.execute(*args, **cmd_options)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/base.py", line 371, in execute
backend_1   |     output = self.handle(*args, **options)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/base.py", line 82, in wrapped
backend_1   |     saved_locale = translation.get_language()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/utils/translation/__init__.py", line 254, in get_language
backend_1   |     return _trans.get_language()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/utils/translation/__init__.py", line 57, in __getattr__
backend_1   |     if settings.USE_I18N:
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 82, in __getattr__
backend_1   |     self._setup(name)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 69, in _setup
backend_1   |     self._wrapped = Settings(settings_module)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 189, in __init__
backend_1   |     raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
backend_1   | django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
backend_1   | Traceback (most recent call last):
backend_1   |   File "/code/manage.py", line 22, in <module>
backend_1   |     execute_from_command_line(sys.argv)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
backend_1   |     utility.execute()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 395, in execute
backend_1   |     self.fetch_command(subcommand).run_from_argv(self.argv)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/base.py", line 330, in run_from_argv
backend_1   |     self.execute(*args, **cmd_options)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/base.py", line 368, in execute
backend_1   |     self.check()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/base.py", line 392, in check
backend_1   |     all_issues = checks.run_checks(
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/checks/registry.py", line 70, in run_checks
backend_1   |     new_errors = check(app_configs=app_configs, databases=databases)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/checks/translation.py", line 43, in check_setting_languages
backend_1   |     for tag, _ in settings.LANGUAGES if not isinstance(tag, str) or not language_code_re.match(tag)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 82, in __getattr__
backend_1   |     self._setup(name)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 69, in _setup
backend_1   |     self._wrapped = Settings(settings_module)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 189, in __init__
backend_1   |     raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
backend_1   | django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
backend_1   | Traceback (most recent call last):
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 224, in fetch_command
backend_1   |     app_name = commands[subcommand]
backend_1   | KeyError: 'build_similarity_index'
backend_1   |
backend_1   | During handling of the above exception, another exception occurred:
backend_1   |
backend_1   | Traceback (most recent call last):
backend_1   |   File "/code/manage.py", line 22, in <module>
backend_1   |     execute_from_command_line(sys.argv)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
backend_1   |     utility.execute()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 395, in execute
backend_1   |     self.fetch_command(subcommand).run_from_argv(self.argv)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 231, in fetch_command
backend_1   |     settings.INSTALLED_APPS
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 82, in __getattr__
backend_1   |     self._setup(name)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 69, in _setup
backend_1   |     self._wrapped = Settings(settings_module)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 189, in __init__
backend_1   |     raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
backend_1   | django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
backend_1   | Traceback (most recent call last):
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 224, in fetch_command
backend_1   |     app_name = commands[subcommand]
backend_1   | KeyError: 'clear_cache'
backend_1   |
backend_1   | During handling of the above exception, another exception occurred:
backend_1   |
backend_1   | Traceback (most recent call last):
backend_1   |   File "/code/manage.py", line 22, in <module>
backend_1   |     execute_from_command_line(sys.argv)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
backend_1   |     utility.execute()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 395, in execute
backend_1   |     self.fetch_command(subcommand).run_from_argv(self.argv)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 231, in fetch_command
backend_1   |     settings.INSTALLED_APPS
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 82, in __getattr__
backend_1   |     self._setup(name)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 69, in _setup
backend_1   |     self._wrapped = Settings(settings_module)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 189, in __init__
backend_1   |     raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
backend_1   | django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
backend_1   | Traceback (most recent call last):
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 224, in fetch_command
backend_1   |     app_name = commands[subcommand]
backend_1   | KeyError: 'createadmin'
backend_1   |
backend_1   | During handling of the above exception, another exception occurred:
backend_1   |
backend_1   | Traceback (most recent call last):
backend_1   |   File "/code/manage.py", line 22, in <module>
backend_1   |     execute_from_command_line(sys.argv)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
backend_1   |     utility.execute()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 395, in execute
backend_1   |     self.fetch_command(subcommand).run_from_argv(self.argv)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 231, in fetch_command
backend_1   |     settings.INSTALLED_APPS
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 82, in __getattr__
backend_1   |     self._setup(name)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 69, in _setup
backend_1   |     self._wrapped = Settings(settings_module)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 189, in __init__
backend_1   |     raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
backend_1   | django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
backend_1   | Running backend server...
backend_1   | production backend starting
backend_1   | Traceback (most recent call last):
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 224, in fetch_command
backend_1   |     app_name = commands[subcommand]
backend_1   | KeyError: 'rqworker'
backend_1   |
backend_1   | During handling of the above exception, another exception occurred:
backend_1   |
backend_1   | Traceback (most recent call last):
backend_1   |   File "/code/manage.py", line 22, in <module>
backend_1   |     execute_from_command_line(sys.argv)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
backend_1   |     utility.execute()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 395, in execute
backend_1   |     self.fetch_command(subcommand).run_from_argv(self.argv)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 231, in fetch_command
backend_1   |     settings.INSTALLED_APPS
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 82, in __getattr__
backend_1   |     self._setup(name)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 69, in _setup
backend_1   |     self._wrapped = Settings(settings_module)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 189, in __init__
backend_1   |     raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
backend_1   | django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
backend_1   | [2021-08-26 14:48:23 +0000] [34] [INFO] Starting gunicorn 20.1.0
backend_1   | [2021-08-26 14:48:23 +0000] [34] [INFO] Listening at: http://0.0.0.0:8001 (34)
backend_1   | [2021-08-26 14:48:23 +0000] [34] [INFO] Using worker: gevent
backend_1   | [2021-08-26 14:48:23 +0000] [36] [INFO] Booting worker with pid: 36
backend_1   | [2021-08-26 14:48:23 +0000] [37] [INFO] Booting worker with pid: 37
backend_1   | [2021-08-26 14:48:23 +0000] [36] [ERROR] Exception in worker process
backend_1   | Traceback (most recent call last):
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/arbiter.py", line 589, in spawn_worker
backend_1   |     worker.init_process()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/workers/ggevent.py", line 146, in init_process
backend_1   |     super().init_process()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/workers/base.py", line 134, in init_process
backend_1   |     self.load_wsgi()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/workers/base.py", line 146, in load_wsgi
backend_1   |     self.wsgi = self.app.wsgi()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/app/base.py", line 67, in wsgi
backend_1   |     self.callable = self.load()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/app/wsgiapp.py", line 58, in load
backend_1   |     return self.load_wsgiapp()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
backend_1   |     return util.import_app(self.app_uri)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/util.py", line 359, in import_app
backend_1   |     mod = importlib.import_module(module)
backend_1   |   File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
backend_1   |     return _bootstrap._gcd_import(name[level:], package, level)
backend_1   |   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
backend_1   |   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
backend_1   |   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
backend_1   |   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
backend_1   |   File "<frozen importlib._bootstrap_external>", line 855, in exec_module
backend_1   |   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
backend_1   |   File "/code/ownphotos/wsgi.py", line 16, in <module>
backend_1   |     application = get_wsgi_application()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/wsgi.py", line 12, in get_wsgi_application
backend_1   |     django.setup(set_prefix=False)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/__init__.py", line 19, in setup
backend_1   |     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 82, in __getattr__
backend_1   |     self._setup(name)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 69, in _setup
backend_1   |     self._wrapped = Settings(settings_module)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 189, in __init__
backend_1   |     raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
backend_1   | django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
backend_1   | [2021-08-26 14:48:23 +0000] [36] [INFO] Worker exiting (pid: 36)
backend_1   | [2021-08-26 14:48:23 +0000] [37] [ERROR] Exception in worker process
backend_1   | Traceback (most recent call last):
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/arbiter.py", line 589, in spawn_worker
backend_1   |     worker.init_process()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/workers/ggevent.py", line 146, in init_process
backend_1   |     super().init_process()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/workers/base.py", line 134, in init_process
backend_1   |     self.load_wsgi()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/workers/base.py", line 146, in load_wsgi
backend_1   |     self.wsgi = self.app.wsgi()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/app/base.py", line 67, in wsgi
backend_1   |     self.callable = self.load()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/app/wsgiapp.py", line 58, in load
backend_1   |     return self.load_wsgiapp()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
backend_1   |     return util.import_app(self.app_uri)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/gunicorn/util.py", line 359, in import_app
backend_1   |     mod = importlib.import_module(module)
backend_1   |   File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
backend_1   |     return _bootstrap._gcd_import(name[level:], package, level)
backend_1   |   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
backend_1   |   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
backend_1   |   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
backend_1   |   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
backend_1   |   File "<frozen importlib._bootstrap_external>", line 855, in exec_module
backend_1   |   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
backend_1   |   File "/code/ownphotos/wsgi.py", line 16, in <module>
backend_1   |     application = get_wsgi_application()
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/wsgi.py", line 12, in get_wsgi_application
backend_1   |     django.setup(set_prefix=False)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/__init__.py", line 19, in setup
backend_1   |     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 82, in __getattr__
backend_1   |     self._setup(name)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 69, in _setup
backend_1   |     self._wrapped = Settings(settings_module)
backend_1   |   File "/usr/local/lib/python3.9/dist-packages/django/conf/__init__.py", line 189, in __init__
backend_1   |     raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
backend_1   | django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
backend_1   | [2021-08-26 14:48:23 +0000] [37] [INFO] Worker exiting (pid: 37)
backend_1   | [2021-08-26 14:48:23 +0000] [34] [WARNING] Worker with pid 37 was terminated due to signal 15
backend_1   | [2021-08-26 14:48:24 +0000] [34] [INFO] Shutting down: Master
backend_1   | [2021-08-26 14:48:24 +0000] [34] [INFO] Reason: Worker failed to boot.
librephotos_backend_1 exited with code 0
derneuere commented 3 years ago

"raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")"

I think you forgot to rename your librephotos.env to just .env.

mcwieger commented 3 years ago

My mistake: I had removed the text shhhhKey when pasting the key. So that was resolved.

I still get the Gateway time-out error, though. Database container looks ok, Redis as well. Frontend only gives a warning about not being able to check for updates. Proxy gives this error:

2021/08/30 08:20:27 [error] 24#24: *16 upstream timed out (110: Connection timed out) while connecting to upstream, client: 172.20.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://172.20.0.5:3000/favicon.ico", host: "192.168.2.201:3001", referrer: "http://192.168.2.201:3001/"
172.20.0.1 - - [30/Aug/2021:08:20:27 +0000] "GET /favicon.ico HTTP/1.1" 504 569 "http://192.168.2.201:3001/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"

And Backend has a slightly bigger log:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/django/db/backends/base/base.py", line 219, in ensure_connection
    self.connect()
  File "/usr/local/lib/python3.9/dist-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/django/db/backends/base/base.py", line 200, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/usr/local/lib/python3.9/dist-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/django/db/backends/postgresql/base.py", line 187, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/usr/local/lib/python3.9/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection timed out
Is the server running on host "db" (172.20.0.6) and accepting
TCP/IP connections on port 5432?

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/code/manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.9/dist-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.9/dist-packages/django/core/management/base.py", line 368, in execute
    self.check()
  File "/usr/local/lib/python3.9/dist-packages/django/core/management/base.py", line 392, in check
    all_issues = checks.run_checks(
  File "/usr/local/lib/python3.9/dist-packages/django/core/checks/registry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/usr/local/lib/python3.9/dist-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "/usr/local/lib/python3.9/dist-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "/usr/local/lib/python3.9/dist-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.9/dist-packages/django/urls/resolvers.py", line 589, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/python3.9/dist-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.9/dist-packages/django/urls/resolvers.py", line 582, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 855, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/code/ownphotos/urls.py", line 16, in <module>
    from api.views import views, photos, albums
  File "/code/api/views/views.py", line 348, in <module>
    class FaceViewSet(viewsets.ModelViewSet):
  File "/usr/local/lib/python3.9/dist-packages/six.py", line 878, in wrapper
    return metaclass(cls.__name__, cls.__bases__, orig_vars)
  File "/code/api/drf_optimize.py", line 102, in __new__
    if queryset:
  File "/usr/local/lib/python3.9/dist-packages/django/db/models/query.py", line 291, in __bool__
    self._fetch_all()
  File "/usr/local/lib/python3.9/dist-packages/django/db/models/query.py", line 1308, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/usr/local/lib/python3.9/dist-packages/django/db/models/query.py", line 53, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/usr/local/lib/python3.9/dist-packages/django/db/models/sql/compiler.py", line 1154, in execute_sql
    cursor = self.connection.cursor()
  File "/usr/local/lib/python3.9/dist-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/django/db/backends/base/base.py", line 259, in cursor
    return self._cursor()
  File "/usr/local/lib/python3.9/dist-packages/django/db/backends/base/base.py", line 235, in _cursor
    self.ensure_connection()
  File "/usr/local/lib/python3.9/dist-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/django/db/backends/base/base.py", line 219, in ensure_connection
    self.connect()
  File "/usr/local/lib/python3.9/dist-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.9/dist-packages/django/db/backends/base/base.py", line 219, in ensure_connection
    self.connect()
  File "/usr/local/lib/python3.9/dist-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/django/db/backends/base/base.py", line 200, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/usr/local/lib/python3.9/dist-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/django/db/backends/postgresql/base.py", line 187, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/usr/local/lib/python3.9/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not connect to server: Connection timed out
Is the server running on host "db" (172.20.0.6) and accepting
TCP/IP connections on port 5432?

I checked the IP addresses and the database indeed is running on 172.20.0.6. The containers all got the suffix '_1', but that shouldn't matter, right?

mcwieger commented 3 years ago

Can this issue be re-opened? Completely stuck, while I'm following every step in the guide...

derneuere commented 3 years ago

It sounded like you original issue was fixed 😅 No docker-compose handles networking for us automatically.

You could try a new db. Maybe it generated a secretKey and now it can't access it.

mcwieger commented 3 years ago

Removed all files from the Docker folders (db/logs/cache/media) and removed all images, so a complete fresh install. Same error message in backend as in this log

derneuere commented 3 years ago

I would guess that something is wrong with the .env files or that something is off in the docker-compose file, but I am not sure. Maybe you could hop onto discord and ask other people who use a Synology NAS how they got it to work.

mcwieger commented 3 years ago

I'm trying on Discord, but it doesn't look like I'm doing anything wrong there.

With regards to the error message: Is the server running on host "db" (172.20.0.6) and accepting TCP/IP connections on port 5432?

Something is going wrong there. Since I couldn't get librephotos to work, I also looked at Photonix, which works with a separate db listening at 5432 as well. I get a similar error message there (of course I'm not trying them at the same time).

Synology also has a postgres db itself (for Audiostation) that's listening on port 5432. I have a feeling this is interfering, even though 5432 of librephotos db is not exposed to the host. Is there any way to configure a different port for the postgres db?

derneuere commented 3 years ago

Hmm, not sure how to do that. Could you start the docker-compose containers with docker-compose up without the -d? There should be a log of the db server why the server isn't starting or accepting connections at the startup.

mcwieger commented 3 years ago

The log provided in Putty are the same as in the log, so no additional info there.

The db log says this:

db_1        | 2021-09-15 11:39:43.590 UTC [1] LOG:  starting PostgreSQL 13.4 (Debian 13.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
db_1        | 2021-09-15 11:39:43.610 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db_1        | 2021-09-15 11:39:43.610 UTC [1] LOG:  listening on IPv6 address "::", port 5432
db_1        | 2021-09-15 11:39:43.649 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1        | 2021-09-15 11:39:43.748 UTC [26] LOG:  database system was shut down at 2021-09-15 07:42:51 UTC
db_1        | 2021-09-15 11:39:43.810 UTC [1] LOG:  database system is ready to accept connections
mcwieger commented 3 years ago

Finally, it looks like I got it...it was a firewall issue. I have pretty strict rules and I had to give access to the Docker range (17.x.x.x)...