首页 > 解决方案 > 如何在docker上将rails与postgresql连接起来?获取:无法连接到服务器:连接被拒绝

问题描述

我遵循了本教程:https ://thoughtbot.com/blog/rails-on-docker

当我跑...

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

...我收到此错误:

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?

标签: ruby-on-railspostgresqldocker

解决方案


而不是使用localhost127.0.0.1使用

苹果电脑

利用docker.for.mac.host.internal

linux

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

视窗

利用host.docker.internal


推荐阅读