DevLog ๐Ÿ“จ/Debugging

[DB] Postgresql@14 error 256

cece00 2023. 11. 15. 01:54

M1 MacOS ํ™˜๊ฒฝ
homebrew๋กœ ์„ค์น˜

๋งฅ์— postgresql ์„ค์น˜ํ•˜๊ณ  psql -d postgres ๋กœ ์ ‘์†ํ•˜๋Š”๋ฐ ์˜ค๋ฅ˜๊ฐ€ ๋‚ฌ๋‹ค.

psql: error: 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?

brew services list ๋กœ ํ™•์ธํ•ด๋ณด๋‹ˆ postgresql@14 error 256 ์—๋Ÿฌ๊ฐ€ ๋œฌ ๊ฒƒ์„ ํ™•์ธํ–ˆ๋‹ค. ์—๋Ÿฌ์ฝ”๋“œ๋งŒ์œผ๋กœ ๊ฒ€์ƒ‰ํ•ด๋ณด๋‹ˆ /opt/homebrew/var/postgresql@14/postmaster.pid๋ฅผ ์‚ญ์ œํ•˜๊ณ  ์žฌ์‹คํ–‰ํ•˜๋ฉด ์ •์ƒ์œผ๋กœ ๋Œ์•„๊ฐ„๋‹ค๋Š” ์ •๋ณด๊ฐ€ ๋งŽ์•˜๋Š”๋ฐ ์• ์ดˆ์— ํ•ด๋‹น ํŒŒ์ผ์ด ์—†์—ˆ๊ณ , ๋”ฐ๋ผ์„œ ์ด ๋ฐฉ๋ฒ•์œผ๋กœ๋Š” ํ•ด๊ฒฐํ•  ์ˆ˜ ์—†์—ˆ๋‹ค.

Service Configuration File ํ™•์ธ

brew services list๋กœ ๋œจ๋Š” .plist ํŒŒ์ผ์€ ์„œ๋น„์Šค์˜ ์„ค์ • ์ •๋ณด์ด๋‹ค. cat {filepath}๋กœ ์—ด์–ด ํ™•์ธํ•˜๋ฉด ํ•ด๋‹น ์„œ๋น„์Šค์˜ ์—๋Ÿฌ ๋กœ๊ทธ ๊ฒฝ๋กœ์™€ ๊ฐ™์€ ์ •๋ณด๋ฅผ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋‹ค.

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    ....

    <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>

์—๋Ÿฌ ๋กœ๊ทธํŒŒ์ผ ๊ฒฝ๋กœ๋ฅผ ํ™•์ธํ•˜๊ณ  cat์œผ๋กœ ์—ด์–ด ํ™•์ธํ•œ๋‹ค.

[49631] LOG:  starting PostgreSQL ...
[49631] LOG:  listening on IPv6 address "::", port 5432
[49631] LOG:  listening on IPv4 address "0.0.0.0", port 5432
[49631] FATAL:  could not open lock file "/tmp/.s.PGSQL.5432.lock": Permission denied
[49631] LOG:  database system is shut down

์œ„์™€ ๊ฐ™์€ ๋กœ๊ทธ๋ฅผ ํ™•์ธํ–ˆ๋‹ค.

/tmp/.s.PGSQL.5432.lock

  • /tmp/.s.PGSQL.5432
  • /tmp/.s.PGSQL.5432.lock

PostgreSQL ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์„œ๋ฒ„๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ์ผ์‹œ์ ์ธ ์†Œ์ผ“ ํŒŒ์ผ ๋˜๋Š” ๋ฝ ํŒŒ์ผ์ด๋‹ค. ๋‘˜ ์ด์ƒ์˜ ํ”„๋กœ์„ธ์Šค๊ฐ€ ํฌํŠธ๋ฅผ ๊ณต์œ ํ•  ์ˆ˜ ์—†์œผ๋ฏ€๋กœ ํ•˜๋‚˜๊ฐ€ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์œผ๋ฉด ๊ทธ๊ฑธ ํ‘œ์‹œํ•˜๋Š” ๋ฝ์ด ํ•„์š”ํ•œ๋ฐ, ์ด ํŒŒ์ผ์ด ๊ทธ ์—ญํ• ์„ ํ•œ๋‹ค. ์ฆ‰, ์ด ์†Œ์ผ“ ํŒŒ์ผ์ด ์žˆ์œผ๋ฉด ์„œ๋ฒ„๊ฐ€ ๊ธฐ๋ณธ 5432 ํฌํŠธ์—์„œ ์‹คํ–‰ ์ค‘์ด๋ผ๊ณ  ๊ฐ„์ฃผํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ๋”ฐ๋ผ์„œ 5432 ํฌํŠธ์—์„œ ์ถฉ๋Œ์ด ๋ฐœ์ƒํ•˜๋Š” ๋ฐ”๋žŒ์— ์‹คํ–‰์ด ๋˜์ง€ ์•Š์•˜๋˜ ๊ฒƒ. ์–ด์ฉ์ง€ ์‹คํ–‰์‹œ์ผœ๋‘” ๊ฒŒ ์—†๋Š”๋ฐ ์•„๋ž˜ ๋กœ๊ทธ๊ฐ€ ๊ณ„์† ๋– ์„œ ๋ญ์ง€? ์‹ถ์—ˆ๋‹ค..

[23122] LOG:  could not bind IPv6 address "::1": Address already in use
[23122] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
[23122] LOG:  could not bind IPv4 address "127.0.0.1": Address already in use
[23122] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
[23122] WARNING:  could not create listen socket for "localhost"
[23122] FATAL:  could not create any TCP/IP sockets
[23122] LOG:  database system is shut down

์„œ๋กœ ๋‹ค๋ฅธ ๋ฒ„์ „์˜ postgresql์„ ์„ค์น˜ํ–ˆ๋‹ค๊ฐ€ ์‚ญ์ œํ•จ & ํ”„๋กœ์„ธ์Šค ๊ฐ•์ œ ์ข…๋ฃŒ์‹œํ‚ค๋Š” ๊ณผ์ •์—์„œ kill -9 [pid] ๋ฅผ ์‚ฌ์šฉํ•ด์„œ.. ๋น„์ •์ƒ ์ข…๋ฃŒ๋˜๋Š” ๋ฐ”๋žŒ์— ํ•ด๋‹น ํŒŒ์ผ์ด ๋ฏธ์ฒ˜ ์‚ญ์ œ๋˜์ง€ ๋ชปํ•œ ๊ฒŒ ์•„๋‹Œ๊ฐ€? ์‹ถ๋‹ค. ๊ฒฐ๊ณผ์ ์œผ๋กœ ์•„๋ž˜ ๋‘ ๋ช…๋ น์–ด๋กœ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ–ˆ๋‹ค.

sudo rm /tmp/.s.PGSQL.5432.lock
sudo rm /tmp/.s.PGSOL.5432

๋.


์ฐธ๊ณ ๋งํฌ
Homebrew Postgresql Service not Starting Resolved
Unable to start Postgres Server because of permission denied on lock file


์˜ค๋Š˜์˜ ๊ตํ›ˆ

  • ๋กœ๊ทธ๋ฅผ ์ž˜ ํ™•์ธํ•  ๊ฒƒ
  • kill -9 ๋‚จ๋ฐœํ•˜์ง€ ์•Š๊ธฐ