When I run the command on docker container backend:
psql -h localhost -p 5432 -U postgres
I receive the following error:
psql: error: connection to server at "localhost" (::1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections? connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections? My docker-compose, dockerfile, database.yml.
I'm running my application via Docker Compose on Ubuntu 24.
psql . -h localhostcommand. This will work only inside the PostgreSQL container, or the host if you expose 5432 to the outside world. Inside the other containers the database will appear as a machine whose name matches the service name, egmydborpostgresordbpsql -h db -p 5432 -U postgresand it worked. But then when I run the commandrails db:createI get the following error: I have the following return: Is the server running locally and accepting connections on that socket? Connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory