Skip to content

Instantly share code, notes, and snippets.

@arpitjalan
Last active October 16, 2024 09:23
Show Gist options
  • Save arpitjalan/8c3c795337adcdb8d27ccb7a77aaee4b to your computer and use it in GitHub Desktop.
Save arpitjalan/8c3c795337adcdb8d27ccb7a77aaee4b to your computer and use it in GitHub Desktop.
PG fix

Error

PGError
could not connect to server: Permission denied
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

Apple M1:

rm /opt/homebrew/var/postgres/postmaster.pid
or ->
rm /opt/homebrew/var/postgresql@14/postmaster.pid

brew services restart postgresql

Intel

rm /usr/local/var/postgres/postmaster.pid

Purge Data

rm -fr /opt/homebrew/var/postgres
initdb /opt/homebrew/var/postgres -E utf8

Alternate Solutions

# Check if `/opt/homebrew/var/postgresql@14` is empty?
# If yes, copy over contents from `/opt/homebrew/var/postgres/`
cp -a /opt/homebrew/var/postgres/ /opt/homebrew/var/postgresql@14

brew unlink postgresql && brew link postgresql
brew unlink postgresql@14 && brew link postgresql@14

brew services stop postgresql@14
brew uninstall postgresql@14
brew uninstall --ignore-dependencies postgresql@14
rm -rf /opt/homebrew/var/postgresql@14
brew install postgresql@14
brew services start postgresql@14

initdb /opt/homebrew/var/postgresql@14

pgvector

psql discourse_development
\dx
CREATE EXTENSION vector;

discourse_development=# \dx
                                    List of installed extensions
   Name   | Version |   Schema   |                            Description
----------+---------+------------+-------------------------------------------------------------------
 hstore   | 1.8     | public     | data type for storing sets of (key, value) pairs
 pg_trgm  | 1.6     | public     | text similarity measurement and index searching based on trigrams
 plpgsql  | 1.0     | pg_catalog | PL/pgSQL procedural language
 unaccent | 1.1     | public     | text search dictionary that removes accents
 vector   | 0.7.4   | public     | vector data type and ivfflat and hnsw access methods
(5 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment