- I am using Postgres as my db for this project.
- My project directory is in my windows system.
- Virtual environment was created in both windows and wsl (ubuntu) with all the dependencies.
- Postgres-16 and pgadmmin4 are installed in my windows.
- I was try to run the server from WSL2 (ubuntu) using
python3 manage.py runserver
. - Getting error in
Exception in thread django-main-thread:
. 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?
- port – 5432 is used by postgres for connection and i was unable to connect to postgres in my windows from WSL.
- PSQL is installed in my WSL
psql --version
psql (PostgreSQL) 14.12 (Ubuntu 14.12-0ubuntu0.22.04.1)
- I tried to add the subnets in my
pg_hba.conf
# IPv4 local connections:
host all all 172.18.64.0/20 scram-sha-256
host all all 127.0.0.1/32 scram-sha-256
host all all 0.0.0.0/0 scram-sha-256
- Double checked the
listen_addresses = '*'
inpostgresql.conf
- I tried to connect the WSL with postgers but get an error
psql -h 'localhost' -U postgres -d encryptdata2
psql: error: 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?