0

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?
troricleba
  • 151
  • 1
  • 3
  • 12
  • You'll have to supply us with the `Dockerfile` and `docker-compose` files. – Todai Jul 14 '19 at 15:06
  • @Today They are in the tutorial I linked. – troricleba Jul 14 '19 at 15:12
  • It sounds like the tutorial is missing a piece of configuration to tell the application where its database is. You might follow up with that tutorial's authors. The SO [ask] page has some suggestions for asking here: generally you need to include enough of your own application's code (in this case relevant fragments of the `Dockerfile`, `docker-compose.yml`, and Rails `database.yml` file) for other people to be able to reproduce your issue. – David Maze Jul 14 '19 at 16:53

1 Answers1

0

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

Community
  • 1
  • 1
NRaghavendra
  • 126
  • 1
  • 7