我正在我的Windows PC上设置项目,我遇到了postgres的问题。
项目设置在docker上。
当我运行docker-compose up
时收到错误
: *** Failed to connect to database dev; trying to create database
/usr/local/bundle/gems/sequel-4.48.0/lib/sequel/adapters/postgres.rb:224:in `initialize': PG::ConnectionBad: could not connect to server: Connection refused (Sequel::DatabaseConnectionError)
Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?
我不知道该怎么办。我已经为TCP-IP安装了microsoft easy-fix,关闭了windows防火墙,将pg_hba.conf
中的所有连接都更改为信任。什么都没有帮助。我没有安装任何防病毒软件。
nmap报告:
Nmap scan report for localhost (127.0.0.1)
Host is up (0.0027s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 995 closed ports
PORT STATE SERVICE
135/tcp open msrpc
445/tcp open microsoft-ds
2068/tcp open avocentkvm
2179/tcp open vmrdp
5432/tcp open postgresql
编辑:
我运行psql -h localhost
并收到
psql: CATASTROPHIC: role "Kamil" does not exist
卡米尔是我的电脑名称。
docker是否可能无法访问localhost上的postgres?
答案 0 :(得分:1)
我必须将环境变量设置为DB_HOST=docker.for.win.localhost