
평소에 거의 끄지 않고 sleep 상태로 사용해오던 m1 맥북을 오랜만에 끄고 휴식을 취하게 해주었다
그리고 다음 날 .. 하던 프로젝트를 계속하려고 postgreSQL을 실행시키는데 오류를 뱉으며 실행 되질 않는다 ㅎ
오류는 다음과 같았다
connection failed: connection to server at "127.0.0.1", port 5432 failed: could not receive data from server: connection refused
bootstrap failed: 5: input/output error try re-running the command as root for richer errors. error: failure while executing;
/bin/launchctl bootstrap gui/501 /users/osubin/library/launchagents/homebrew.mxcl.postgresql@14.plistexited with 5.
또한 brew services를 통해서 확인해보니
postgresql@14가 error 256로 실행이 되지 않고 있었다
구글링을 해보니 (m1의 경우) /opt/homebrew/var/postgresql@14/postmaster.pid, (그 외) /usr/bin/var/postgresql@14/postmaster.pid 를 삭제하고 다시 재시작하면 된단다.
삭제 명령어
rm /opt/homebrew/var/postgresql@14/postmaster.pid
하지만 이 방법은 나에겐 먹히지 않았다
삭제한 후에 재시작을 해봐도 똑같이 256 오류로 시작이 되질 않았다.
뭐가 문젠지 확인하기 위해 postgreSQL의 서비스 로그를 확인하였다.
로그 파일의 위치는
1. brew services 명령어를 통해 postgresql@14.plist의 위치를 알아낸다.
2. 해당 위치의 plist 파일을 열면 log 파일의 위치가 나온다.
(참조 블로그)
아래는 postgresql@14.plist 파일 안의 내용이다.
... 중략
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/opt/homebrew/var/log/postgresql@14.log</string>
<key>StandardOutPath</key>
<string>/opt/homebrew/var/log/postgresql@14.log</string>
<key>WorkingDirectory</key>
<string>/opt/homebrew</string>
</dict>
</plist>
error와 output이 /opt/homebrew/var/log/postgresql@14.log에 저장되고 있음을 확인할 수 있다.
로그 파일을 확인해보니 다음과 같이 로그가 찍혀있었다.
2024-10-07 14:58:59.374 KST [7573] LOG: listening on IPv6 address "::1", port 5432
2024-10-07 14:58:59.374 KST [7573] LOG: listening on IPv4 address "127.0.0.1", port 5432
2024-10-07 14:58:59.375 KST [7573] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2024-10-07 14:58:59.376 KST [7573] LOG: invalid authentication method "0.0.0.0/0"
2024-10-07 14:58:59.376 KST [7573] CONTEXT: line 96 of configuration file "/opt/homebrew/var/postgresql@14/pg_hba.conf"
2024-10-07 14:58:59.376 KST [7573] FATAL: could not load pg_hba.conf
2024-10-07 14:58:59.376 KST [7573] LOG: database system is shut down
configuration file인 pg_hba.conf 에 invalid authentication method "0.0.0.0/0"가 존재해서 could not load 하단다 .. 난 만진 적도 없는데

실제로 0.0.0.0/0이 존재하는 라인을 확인했다 ㅎ
이제 이걸 어떻게 고칠까?
local replication all 0.0.0.0/0 trust
문제가 되는 라인이다.
일단 결과적으로는 0.0.0.0/0 을 그냥 삭제해버리면 된다.
사실 처음 postgreSQL을 설정할 때 pg_hba.conf 파일을 초기 설정하면서 만졌던 기억이 있는데(결국 만진 적 있었던 거임) 그 때 설정값을 잘못 넣었던 것 같다.
local 설정이라 IP 범위 제한이 필요하지 않음에도 불구하고 들어가 있으니 잘못된 설정이라 오류를 뱉었던 것으로 예상된다 ㅠ
완전 초기에 했던 설정이라 그동안은 왜 쌩쌩 잘 돌아갔는지 이해가 살짝 안 가긴 하지만요 ?

어쨌거나 해결 완료 ✅
결국 모든 에러 해결 방법은 ....
댓글 작성 후 삭제 했는데도 1개의 댓글이 있다고 뜨는 오류 발견 +_+