PG::ConnectionBad:运行export DATABASE_URL=postgres://$(whoami)



运行

后收到此错误
export DATABASE_URL=postgres://$(whoami)

命令行。现在当我运行命令

$$ rake db:migrate

这是完整的错误

rake aborted!
PG::ConnectionBad: could not translate host name "Jillian" to address: nodename nor servname provided, or not known
Tasks: TOP => db:migrate

如何修复postgres?

PS我是按照这个教程https://devcenter.heroku.com/articles/heroku-postgresql#local-setup为python应用程序设置pg,但我可能有一个旧版本的pg。我试图至少让postgres回到我运行^

之前的样子

....还有大家期待已久的答案:

如果您通过运行export DATABASE_URL=...弄乱了您的开发环境,如果您处于与上面类似的情况并且已经在每个项目中设置了环境,请通过运行

来解决此问题。
unset DATABASE_URL

我的解决方案是更改/etc/hosts文件

在我的应用程序中。yml文件被定义:

databases:
  crm:
    adapter: postgresql
    host: postgresql

和错误看起来像

PG::ConnectionBad:
  could not translate host name "postgresql" to address: nodename nor servname provided, or not known
因此,我编辑了我的/etc/hosts文件(使用sudo):sudo vim/etc/hosts并添加了下一行
127.0.0.1       postgresql

之后一切正常

最新更新