Open LSY310 opened 1 month ago
장고와 DB연결이 실패한것으로 보아 DB 컨테이너가 running 상태가 아닐 수도 있고, app/settings.py와 .env의 DB 연결 내용을 한번더 확인해 보시는 것도 좋을 것 같습니다. 아니면 5432포트를 다른 프로세스가 사용중일 수도 있으니 만약 같은 문제가 발생한다면 [ lsof -i :5432 ]명령어를 실행해서 포트를 확인해주시기 바랍니다 전 이게 가장 가능성이 높다고 생각하는데 도커 볼륨 문제일 수 도 있습니다 기존 볼룸을 [ docker-compose down -v ] 명령어를 사용해 지워보시고 docker-compose up -d 하셔도 같은 문제하면 디버깅 회의 한번 같이 하시는 걸로 하죠.
DB 밀고 다시 재생성으로 오류 해결
.env에 db 정보 안넣어둠
(oz-03-main-006-be-py3.12) (base) mac@macui-MacBookPro han_cycle % python manage.py migrate Traceback (most recent call last): File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 275, in ensure_connection self.connect() File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner return func(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 256, in connect self.connection = self.get_new_connection(conn_params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner return func(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/db/backends/postgresql/base.py", line 277, in get_new_connection connection = self.Database.connect(conn_params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/psycopg/connection.py", line 119, in connect raise last_ex.with_traceback(None) psycopg.OperationalError: connection is bad: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket?
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/Users/mac/oz_03_main-006-BE/han_cycle/manage.py", line 22, in
main()
File "/Users/mac/oz_03_main-006-BE/han_cycle/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/core/management/init.py", line 442, in execute_from_command_line
utility.execute()
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/core/management/init.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv
self.execute(*args, cmd_options)
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute
output = self.handle(*args, *options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/core/management/base.py", line 107, in wrapper
res = handle_func(args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/core/management/commands/migrate.py", line 100, in handle
self.check(databases=[database])
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/core/management/base.py", line 486, in check
all_issues = checks.run_checks(
^^^^^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/core/checks/registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/core/checks/model_checks.py", line 36, in check_all_models
errors.extend(model.check(kwargs))
^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/db/models/base.py", line 1617, in check
cls._check_constraints(databases),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/db/models/base.py", line 2467, in _check_constraints
connection.features.supports_nulls_distinct_unique_constraints
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/utils/functional.py", line 47, in get
res = instance.dict[self.name] = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/db/backends/postgresql/features.py", line 141, in is_postgresql_15
return self.connection.pg_version >= 150000
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/utils/functional.py", line 47, in get
res = instance.dict[self.name] = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/db/backends/postgresql/base.py", line 438, in pg_version
with self.temporary_connection():
File "/usr/local/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 137, in enter
return next(self.gen)
^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 691, in temporary_connection
with self.cursor() as cursor:
^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner
return func(args, kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 316, in cursor
return self._cursor()
^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 292, in _cursor
self.ensure_connection()
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 274, in ensure_connection
with self.wrap_database_errors:
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/db/utils.py", line 91, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 275, in ensure_connection
self.connect()
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, *kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 256, in connect
self.connection = self.get_new_connection(conn_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner
return func(args, kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/django/db/backends/postgresql/base.py", line 277, in get_new_connection
connection = self.Database.connect(**conn_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mac/oz_03_main-006-BE/.venv/lib/python3.12/site-packages/psycopg/connection.py", line 119, in connect
raise last_ex.with_traceback(None)
django.db.utils.OperationalError: connection is bad: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
"/tmp/.s.PGSQL.5432" 소켓 파일이 없다는 것으로 보아 PostgreSQL 서버가 실행되지 않거나, 실행된 상태에서 해당 소켓 파일이 제대로 생성되지 않았을 가능성이 있음 -> ec2는 실행중인것 확인 소켓파일..?은 뭔지 ㅁ르겠네