1

I am struggling to troubleshoot the startup error for postgres on mac Big Sur. The symlink exits for LaunchAgents as homebrew.mxcl.postgresql.plist

But when I run

postgres -D /usr/local/var/postgres

I get output

FATAL:  could not open directory "pg_notify": No such file or directory
LOG:  database system is shut down

Does anyone know about a solution for this?

godhar
  • 1,128
  • 1
  • 14
  • 34
  • 1
    Check this: https://stackoverflow.com/questions/66620279/how-to-get-postgres-to-start-on-big-sur – Frank N Stein Jun 06 '22 at 11:31
  • Thanks buddy, that did help actually. To anyone else wondering, use the official [postgresapp](https://postgresapp.com/) and save yourself the hassle. – godhar Jun 06 '22 at 12:21

2 Answers2

4

I had the same phenomenon happen to me. Uninstalling postgresql, deleting the /usr/local/var/postgres/ directory and reinstalling it solved the problem.

$ ls /usr/local/var/postgres/
PG_VERSION              global                  pg_ident.conf           pg_multixact            pg_wal                  postgresql.auto.conf
base                    pg_hba.conf             pg_logical              pg_subtrans             pg_xact                 postgresql.conf
$ brew uninstall postgresql
$ rm -rf  /usr/local/var/postgres
$ brew install postgresql
$ ls /usr/local/var/postgres/
PG_VERSION              pg_commit_ts            pg_ident.conf           pg_notify               pg_snapshots            pg_subtrans             pg_wal                  postgresql.conf
base                    pg_dynshmem             pg_logical              pg_replslot             pg_stat                 pg_tblspc               pg_xact
global                  pg_hba.conf             pg_multixact            pg_serial               pg_stat_tmp             pg_twophase             postgresql.auto.conf

kazuyuki
  • 41
  • 2
2

I tried almost all of the answers in this question and this other one and these are the steps that finally worked for me to get postgres to start

  • tail the logs for postgres.
    • the path needs to be updated depending on where postgres is installed, and your version. I am using postgresql@14 on an m1 Monterey and installed it with homebrew.

    • i finally found the path i needed to look at using this article.

    • tail /opt/homebrew/var/log/postgresql@14.log

output shows this:

2023-02-03 15:33:49.294 CST [82651] FATAL:  could not open directory "pg_notify": No such file or directory
2023-02-03 15:33:49.294 CST [82651] LOG:  database system is shut down
  • go to the / directory and cd opt/homebrew/var/postgresql@14

  • create the missing directory (maybe this is a different directory for you)

    • mkdir pg_notify
  • repeat this process for all missing directories.

    • I needed to mkdir for pg_tblspc, pg_replslot, pg_twophase, pg_stat_tmp, pg_logical/snapshots, pg_logical/mappings, pg_commit_ts, pg_snapshots, & pg_commit_ts but i recommend you specifically run the tail command each time to make sure you are not missing different directories & files than me.

finally after running the tail command repeatedly after creating each missing directory, I got this output.

2023-02-03 15:49:18.909 CST [85772] LOG:  redo done at 0/17211D8 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
2023-02-03 15:49:18.914 CST [85771] LOG:  database system is ready to accept connections

i was then able to create & migrate my db in my project ・ᴗ・