Why does Phoenix (ecto/Postgresx) fail to Connect in dev

Ok, so I figured it out. It is a simple mistake on my part in the end. Though an easy one to make.

I am using Boxen on my Mac and it changes the port to 15432 for some reason.

I may have landed on this sooner if the mix ecto.create had failed. Not sure why that works.

Hopefully this will help others in the future


This happened to me twice, after macOS crashed.

Most recently I used this:

Fix 1

  1. Run postgres -D /usr/local/var/postgres
  2. 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"?
    
  3. 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