Hi everyone,
I’m working on the Relational Databases certification and using the Docker-based environment. However, when I try to connect to PostgreSQL using the following command:
psql --username=freecodecamp --dbname=postgres
I get this error:
psql: error: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I’ve tried checking whether the PostgreSQL service is running, and I also made sure that the `psql` command works in Git Bash on my local machine.
Here’s more context:
* I’m on Windows
* I’m using the **freeCodeCamp-provided container/terminal** (e.g., `camper@...:/workspace/project`).
* The error occurs inside the freeCodeCamp terminal , not my local setup.
Has anyone else faced this issue? Is there something I need to manually start inside the container to get the PostgreSQL server running?
Also i tried these steps:
sudo cp ./.freeCodeCamp/pg_hba.conf /etc/postgresql/12/main/pg_hba.conf
sudo chown -R postgres:postgres /var/lib/postgresql/12/main
sudo service postgresql restart
echo "SELECT 'CREATE USER freecodecamp WITH CREATEDB' WHERE NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname='freecodecamp')\gexec" | psql -U postgres -X
cp: cannot stat './.freeCodeCamp/pg_hba.conf': No such file or directory
it gives this error
