简体   繁体   中英

How to connect rails with postgresql on docker? Getting: could not connect to server: Connection refused

I followed this tutorial: https://thoughtbot.com/blog/rails-on-docker

When I run ...

docker-compose run web rake db:create db:setup

... I get this error:

could not connect to server: Connection refused
        Is the server running on host "127.0.0.1" and accepting
        TCP/IP connections on port 5432?

instead of using localhost or 127.0.0.1 use

Mac

use docker.for.mac.host.internal

linux

try https://stackoverflow.com/a/52858101/5616944

Windows

use host.docker.internal

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM