Skip to content

Instantly share code, notes, and snippets.

@shamshirz
Created October 20, 2020 20:35
Show Gist options
  • Save shamshirz/6b36deb7c916e1bd5383aec51b31ed01 to your computer and use it in GitHub Desktop.
Save shamshirz/6b36deb7c916e1bd5383aec51b31ed01 to your computer and use it in GitHub Desktop.
Troubleshooting a homebrew installed postgres
# How did you discover the issue?
# Elixir
# 15:22:11.284 [error] GenServer #PID<0.3763.0> terminating
#** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
# psql
# psql -h 127.0.0.1 -d postgres -U postgres -d crowbar_test
# Hunches about what went wrong. Homebrew upgrade or OS upgrade corrupted the data. We did something foolish?
> brew services
# Probably indicates that postgres is working fine
# Name Status User Plist
# postgresql started me /Users/me/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
> postgres -D /usr/local/var/postgres
# 2020-10-20 15:56:44.132 EDT [27460] FATAL: database files are incompatible with server
# 2020-10-20 15:56:44.132 EDT [27460] DETAIL: The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 13.0.
# That was useful!
# Solutions - rollback our version, upgrade the data? or wipe everything and start new :)
# 1. Start Fresh
> rm -rf /usr/local/var/postgres
> initdb /usr/local/var/postgres -E utf8
> /usr/local/bin/createuser -s postgres
# 2. Upgrade the files
> brew info postgresql
> brew postgresql-upgrade-database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment