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 500 cannot connect to DB #1275

Closed
rickbn96 opened this issue Dec 29, 2024 · 2 comments · Fixed by #1276
Closed

error 500 cannot connect to DB #1275

rickbn96 opened this issue Dec 29, 2024 · 2 comments · Fixed by #1276
Assignees
Labels
bug Something isn't working

Comments

@rickbn96
Copy link

I'm in a VM and appling the remote situation, here the error, tried in compose-remote and also in build but same error

[+] Running 3/0
✔ Container backend Created 0.0s
✔ Container frontend Created 0.0s
✔ Container caddy Created 0.0s
Attaching to backend, caddy, frontend
frontend | Listening on 0.0.0.0:3000
caddy | {"level":"info","ts":1735506442.0838776,"msg":"using adjacent Caddyfile"}
caddy | {"level":"info","ts":1735506442.0844517,"msg":"adapted config to JSON","adapter":"caddyfile"}
caddy | {"level":"warn","ts":1735506442.08446,"msg":"Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies","adapter":"caddyfile","file":"Caddyfile","line":2}
caddy | {"level":"info","ts":1735506442.0848393,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
caddy | {"level":"info","ts":1735506442.0849898,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000593180"}
caddy | {"level":"info","ts":1735506442.0851846,"logger":"http.auto_https","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
caddy | {"level":"info","ts":1735506442.0853305,"logger":"pki.ca.local","msg":"root certificate is already trusted by system","path":"storage:pki/authorities/local/root.crt"}
caddy | {"level":"info","ts":1735506442.0854654,"logger":"http","msg":"enabling HTTP/3 listener","addr":":8443"}
caddy | {"level":"info","ts":1735506442.0855052,"msg":"failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 7168 kiB, got: 416 kiB). See https://github.com/quic-go/quic-go/wiki/UDP-Buffer-Sizes for details."}
caddy | {"level":"info","ts":1735506442.0856392,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
caddy | {"level":"info","ts":1735506442.0856757,"logger":"http.log","msg":"server running","name":"remaining_auto_https_redirects","protocols":["h1","h2","h3"]}
caddy | {"level":"info","ts":1735506442.0856857,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["ciso.abt.tools"]}
caddy | {"level":"warn","ts":1735506442.0858767,"logger":"tls","msg":"stapling OCSP","error":"no OCSP stapling for [ciso.abt.tools]: no OCSP server specified in certificate","identifiers":["ciso.abt.tools"]}
caddy | {"level":"info","ts":1735506442.0860214,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}
caddy | {"level":"info","ts":1735506442.086039,"msg":"serving initial configuration"}
caddy | {"level":"info","ts":1735506442.096772,"logger":"tls","msg":"storage cleaning happened too recently; skipping for now","storage":"FileStorage:/data/caddy","instance":"13a1117a-f04e-4b10-bb7f-c4094de25236","try_again":1735592842.096771,"try_again_in":86399.9999997}
caddy | {"level":"info","ts":1735506442.0968058,"logger":"tls","msg":"finished cleaning storage units"}
backend | install: can't create 'db/django_secret_key': Permission denied
backend | generating initial Django secret key
backend | startup.sh: line 13: db/django_secret_key: No such file or directory
backend | Django secret key read from file
backend | 2024-12-29T21:07:22.684487Z [info ] BASE_DIR: /code [ciso_assistant.settings] ciso_assistant_url=https://ciso.abt.tools:8443
backend | 2024-12-29T21:07:22.684603Z [info ] VERSION: v2.0.0 [ciso_assistant.settings] ciso_assistant_url=https://ciso.abt.tools:8443
backend | 2024-12-29T21:07:22.684680Z [info ] BUILD: a373fef [ciso_assistant.settings] ciso_assistant_url=https://ciso.abt.tools:8443
backend | 2024-12-29T21:07:22.684918Z [info ] DEBUG mode: True [ciso_assistant.settings] ciso_assistant_url=https://ciso.abt.tools:8443
backend | 2024-12-29T21:07:22.684980Z [info ] CISO_ASSISTANT_URL: https://ciso.abt.tools:8443 [ciso_assistant.settings] ciso_assistant_url=https://ciso.abt.tools:8443
backend | 2024-12-29T21:07:22.685039Z [info ] ALLOWED_HOSTS: ['backend', 'ciso.abt.tools'] [ciso_assistant.settings] ciso_assistant_url=https://ciso.abt.tools:8443
backend | 2024-12-29T21:07:22.685149Z [info ] SQLITE_FILE: /code/db/ciso-assistant.sqlite3 [ciso_assistant.settings] ciso_assistant_url=https://ciso.abt.tools:8443
backend | 2024-12-29T21:07:22.685207Z [info ] DATABASE ENGINE: django.db.backends.sqlite3 [ciso_assistant.settings] ciso_assistant_url=https://ciso.abt.tools:8443
backend | Traceback (most recent call last):
backend | File "/code/.venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 279, in ensure_connection
backend | self.connect()
backend | File "/code/.venv/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner
backend | return func(*args, **kwargs)
backend | ^^^^^^^^^^^^^^^^^^^^^
backend | File "/code/.venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 256, in connect
backend | self.connection = self.get_new_connection(conn_params)
backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend | File "/code/.venv/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner
backend | return func(*args, **kwargs)
backend | ^^^^^^^^^^^^^^^^^^^^^
backend | File "/code/.venv/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py", line 200, in get_new_connection
backend | conn = Database.connect(**conn_params)
backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend | sqlite3.OperationalError: unable to open database file
backend |
backend | The above exception was the direct cause of the following exception:
backend |
backend | Traceback (most recent call last):
backend | File "/code/manage.py", line 23, in
backend | main()
backend | File "/code/manage.py", line 19, in main
backend | execute_from_command_line(sys.argv)
backend | File "/code/.venv/lib/python3.12/site-packages/django/core/management/init.py", line 442, in execute_from_command_line
backend |
backend | utility.execute()
backend | File "/code/.venv/lib/python3.12/site-packages/django/core/management/init.py", line 436, in execute
backend | self.fetch_command(subcommand).run_from_argv(self.argv)
backend | File "/code/.venv/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv
backend | self.execute(*args, **cmd_options)
backend | File "/code/.venv/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute
backend | output = self.handle(*args, **options)
backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend | File "/code/.venv/lib/python3.12/site-packages/django/core/management/commands/showmigrations.py", line 67, in handle
backend | return self.show_list(connection, options["app_label"])
backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend | File "/code/.venv/lib/python3.12/site-packages/django/core/management/commands/showmigrations.py", line 86, in show_list
backend | loader = MigrationLoader(connection, ignore_no_migrations=True)
backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend | File "/code/.venv/lib/python3.12/site-packages/django/db/migrations/loader.py", line 58, in init
backend | self.build_graph()
backend | File "/code/.venv/lib/python3.12/site-packages/django/db/migrations/loader.py", line 235, in build_graph
backend | self.applied_migrations = recorder.applied_migrations()
backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend | File "/code/.venv/lib/python3.12/site-packages/django/db/migrations/recorder.py", line 89, in applied_migrations
backend | if self.has_table():
backend | ^^^^^^^^^^^^^^^^
backend | File "/code/.venv/lib/python3.12/site-packages/django/db/migrations/recorder.py", line 63, in has_table
backend | with self.connection.cursor() as cursor:
backend | ^^^^^^^^^^^^^^^^^^^^^^^^
backend | File "/code/.venv/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner
backend | return func(*args, **kwargs)
backend | ^^^^^^^^^^^^^^^
backend | ^^^^
backend | ^^
backend | File "/code/.venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 320, in cursor
backend | return self._cursor()
backend |
backend | ^^^
backend | ^^^^
backend | ^^^^
backend | ^^^
backend |
backend | File "/code/.venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 296, in _cursor
backend |
backend | self.ensure_connection()
backend | File "/code/.venv/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner
backend | return func(*args, **kwargs)
backend |
backend |
backend | ^^^
backend | ^^^^^^^^^^^^^
backend | ^^^^
backend | ^
backend | File "/code/.venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 278, in ensure_connection
backend | with self.wrap_database_errors:
backend | ^^^^^^^^^^^^^^^^^^
backend | ^^^^^^^
backend | File "/code/.venv/lib/python3.12/site-packages/django/db/utils.py", line 91, in exit
backend | raise dj_exc_value.with_traceback(traceback) from exc_value
backend | File "/code/.venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 279, in ensure_connection
backend | self.connect()
backend | File "/code/.venv/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner
backend | return func(*args, **kwargs)
backend | ^^^^^^^^^^^^^^^^^^^^^
backend | File "/code/.venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 256, in connect
backend | self.connection = self.get_new_connection(conn_params)
backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend | File "/code/.venv/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner
backend | return func(*args, **kwargs)
backend | ^^^^^^^^^^^^^^^^^^^^^
backend | File "/code/.venv/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py", line 200, in get_new_connection
backend | conn = Database.connect(**conn_params)
backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend | django.db.utils.OperationalError: unable to open database file
backend | database not ready; waiting

@ab-smith
Copy link
Contributor

ok thank you, this is the related to the database not having enough time to initialize, slowing it a bit down in the next build

@ab-smith ab-smith added the bug Something isn't working label Dec 29, 2024
@ab-smith ab-smith self-assigned this Dec 29, 2024
@ab-smith ab-smith reopened this Dec 29, 2024
@ab-smith
Copy link
Contributor

Allright, should be fixed now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants