4

I have installed postgresql@14 via brew on my Mac M2.

Now, when I do brew services I get this output

postgresql@14 error  256 headmaster ~/Library/LaunchAgents/[email protected]

Can anyone help and tell me, how to check where the actual error is?

UPD1

Based on code error 256 found some info with command tail -f /opt/homebrew/var/log/[email protected]

2022-11-26 12:05:14.229 +03 [2139] LOG:  starting PostgreSQL 14.6 (Homebrew) on aarch64-apple-darwin22.1.0, compiled by Apple clang version 14.0.0 (clang-1400.0.29.202), 64-bit
2022-11-26 12:05:14.231 +03 [2139] LOG:  could not bind IPv6 address "::1": Address already in use
2022-11-26 12:05:14.231 +03 [2139] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2022-11-26 12:05:14.231 +03 [2139] LOG:  could not bind IPv4 address "127.0.0.1": Address already in use
2022-11-26 12:05:14.231 +03 [2139] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2022-11-26 12:05:14.231 +03 [2139] WARNING:  could not create listen socket for "localhost"
2022-11-26 12:05:14.231 +03 [2139] FATAL:  could not create any TCP/IP sockets
2022-11-26 12:05:14.232 +03 [2139] LOG:  database system is shut down

UPD2

based on the error log I checked my etc/hosts

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section

Not sure, if I should change anything here

2
  • 2
    Well is anything else running on port 5432? Like perhaps kubernetes?
    – mmmmmm
    Commented Nov 26, 2022 at 11:41
  • @mmmmmm - Yes. there were another process on that port. Many thanks. If you want, you can post your comment as an answer and I will accept it
    – Headmaster
    Commented Nov 26, 2022 at 14:10

2 Answers 2

3

The error messages give information that needs to be investigated.

HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.

So check if port 5432 is being used. If so put postgress on another port

2

Postgres uses a file to tell if an instance is already running. The file should be deleted when the postgres process exits. In my case, postgres was no longer running but the file was still there, causing postgres to refuse to start. Looks like your logs are suggesting the same.

To check if no other postgres instance is running:

lsof -i -P -n | grep LISTEN | grep 5432

If not, the solution for me was to remove the file with the command below:

rm /opt/homebrew/var/postgresql@14/postmaster.pid
2
  • Wouldn't it be prudent to check first whether another postgres process is still running?
    – nohillside
    Commented Feb 13, 2023 at 11:51
  • Sure, I'll update the answer.
    – alextes
    Commented Feb 17, 2023 at 9:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .