I’m having trouble connecting to the PostgreSQL server on my local machine (Linux Fedora). I gathered that this isn’t a Django/Python issue, but rather a specific PostgreSQL problem.
I went through 3 different similar Stack Overflow questions, which strongly suggested changing the pg_hfa.conf file from ident to either true or md5 which I did in both cases. After this, I reloaded PostgreSQL server with the following in my Linux terminal sudo service postgresql restart
This method did not work when I ran python manage.py migrate in my VS Code console and continue to get the error django.db.utils.OperationalError: connection to server at "localhost" (::1), port 5432 failed: FATAL: Ident authentication failed for user "postgres".
Here is my pg_hfa.conf with the modifications I made
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
# local replication all peer
# host replication all 127.0.0.1/32 ident
# host replication all ::1/128 ident
This may his help or not, but here are the most recent logs for PostgreSQL
2025-01-06 16:26:51.273 MST [5612] LOG: database system was shut down in recovery at 2025-01-06 14:08:38 MST
2025-01-06 16:26:51.275 MST [5612] LOG: database system was not properly shut down; automatic recovery in progress
2025-01-06 16:26:51.288 MST [5612] LOG: redo starts at 0/37DB2C8
2025-01-06 16:26:51.288 MST [5612] LOG: invalid record length at 0/37DB300: expected at least 24, got 0
2025-01-06 16:26:51.288 MST [5612] LOG: redo done at 0/37DB2C8 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
2025-01-06 16:26:51.298 MST [5720] LOG: checkpoint starting: end-of-recovery immediate wait
2025-01-06 16:26:51.309 MST [5720] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.002 s, total=0.013 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB; lsn=0/37DB300, redo lsn=0/37DB300
2025-01-06 16:27:06.387 MST [6596] ERROR: canceling statement due to user request
2025-01-06 16:27:06.387 MST [6584] ERROR: canceling statement due to user request
2025-01-06 16:27:06.399 MST [5720] LOG: shutting down
2025-01-06 16:27:06.401 MST [5720] LOG: checkpoint starting: shutdown immediate
2025-01-06 16:27:06.420 MST [5720] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.001 s, total=0.021 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=0 kB; lsn=0/37DB3B0, redo lsn=0/37DB3B0
The SO links to the similar problems are provided below.
psql: FATAL: Ident authentication failed for user "postgres"
PostgreSQL - FATAL: Ident authentication failed for user
Please I need some kind of guidance, I’ve been stuck on this particular issue for days now and examined several other similar problems via Googling Stack Overflow.