PG::ConnectionBad: could not translate host name error after running export DATABASE_URL=postgres://$(whoami)

Jillian Hoenig picture Jillian Hoenig · Aug 17, 2016 · Viewed 12.1k times · Source

I received this error after running

export DATABASE_URL=postgres://$(whoami)

on the command line. Now when I run the command

$$ rake db:migrate

This is the full error

rake aborted!
PG::ConnectionBad: could not translate host name "Jillian" to address: nodename nor servname provided, or not known

Tasks: TOP => db:migrate

How can I fix postgres?

PS I was following this tutorial https://devcenter.heroku.com/articles/heroku-postgresql#local-setup to set up pg for a python app, but I may have an old version of pg. I'm trying to at least get postgres back to how it was before I ran that^

Answer

Jillian Hoenig picture Jillian Hoenig · Sep 9, 2016

....And the answer you've all been waiting for:

If you've messed up your development environment by running export DATABASE_URL=..., if you'e in a similar sitaution to the one above and already set up your environments within each project, resolve this issue by running

unset DATABASE_URL