我在运行以下命令后收到此错误
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回到我运行它之前的样子。
发布于 2016-09-09 11:05:25
....And你一直在等待的答案:
如果您通过运行导出DATABASE_URL=...弄乱了开发环境,如果您所在的站点与上面的站点相似,并且已经在每个项目中设置了您的环境,那么可以通过运行以下命令来解决此问题
unset DATABASE_URL发布于 2020-01-14 09:42:13
我的解决方案是更改/etc/hosts文件
在我的application.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在那之后,一切都很好。
https://stackoverflow.com/questions/39004608
复制相似问题