The Dev Pages

A knowledge base for web applications development (and beyond)

Archive for the ‘Elixir and Phoenix’ Category




10:36:54.086 [error] Postgrex.Protocol (#PID<0.522.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (127.0.0.1:5432): connection refused - :econnrefused

psql: error: could not connect to server: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

Even if brew services restart postgres is successful, there may be an error occurring, view your log, which for me with homebrew’s install was tail -n 50 /usr/local/var/log/postgres.log. If you see something like the following, you may need to switch a package version back to something older:

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
Referenced from: /usr/local/opt/postgresql/bin/postgres
Reason: image not found

For me, after an OS update, the icu4c package had been changed, so I needed to switch it back, using brew switch icu4c 64.2




Issue: Getting the (current or otherwise) date for a specific timezone can be involve some trickiness.

Example: I want to show the current date in New York, even though I reside in Austin, TX. If it is 12/11/2020 11:39 PM CT:

  • The display for NY data should show 12/12/2020
  • A display for Austin, TX would show 12/11/20202

One solution:

NOTE: When dealing with DateTimes to save to a database, leaving the microseconds on can cause issues. I’m surprised the DateTime result doesn’t default to the more compatible format (TBD on whether from Elixir or Timex). See https://github.com/riverrun/phauxth-example/issues/10