phoenix postgres connection refused code example

Example: postgrex.protocol failed to connect

This happened to me twice, after macOS crashed.
Most recently I used this:
Fix 1
Run postgres -D /usr/local/var/postgres
Copy the number after PID if you see something like this:
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 379) running in data directory "/usr/local/var/postgres"?
kill -9 PID with the process # in place of PID.
The steps that worked for me previously:
Fix 2
brew update
brew upgrade
brew postgresql-upgrade-database

Tags:

Misc Example