PG::ConnectionBad Connection refused

I’m running a ruby on rails application
With docker, postgresql and virtualbox

but when I run the command

docker-compose up --build

and open it in the browser:

I get this error:

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

What can this be?

Source: Docker Questions