PG::ConnectionBad: 运行 导出后无法转换主机名错误 DATABASE_URL=postgres://$(whoami)
PG::ConnectionBad: could not translate host name error after running export DATABASE_URL=postgres://$(whoami)
我在 运行ning
之后收到这个错误
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 文件
在我的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
之后一切正常
我在 运行ning
之后收到这个错误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 文件
在我的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
之后一切正常