I\'ve been following this guide of how to set up a Rails Development Environment using Docker: Setting Up A Rails Development Environment Using Docker.
You try to connect to localhost:5432 in other words you try to connect to the web container, but your point is db. Just specify Database host in your application like db