Skip to content
Fix Code Error

Postgresql: password authentication failed for user “postgres”

March 13, 2021 by Code Error
Posted By: Anonymous

I have installed PostgreSQL 8.4, Postgres client and Pgadmin 3. Authentication failed for user “postgres” for both console client and Pgadmin. I have typed user as “postgres” and password “postgres”, because it worked before. But now authentication is failed. I did it before a couple of times without this problem. What should I do? And what happens?

psql -U postgres -h localhost -W
Password for user postgres: 
psql: FATAL:  password authentication failed for user "postgres"
FATAL:  password authentication failed for user "postgres"

Solution

If I remember correctly the user postgres has no DB password set on Ubuntu by default. That means, that you can login to that account only by using the postgres OS user account.

Assuming, that you have root access on the box you can do:

sudo -u postgres psql

If that fails with a database "postgres" does not exists error, then you are most likely not on a Ubuntu or Debian server 🙂 In this case simply add template1 to the command:

sudo -u postgres psql template1

If any of those commands fail with an error psql: FATAL: password authentication failed for user "postgres" then check the file /etc/postgresql/8.4/main/pg_hba.conf: There must be a line like this as the first non-comment line:

local   all         postgres                          ident

For newer versions of PostgreSQL ident actually might be peer. That’s OK also.

Inside the psql shell you can give the DB user postgres a password:

ALTER USER postgres PASSWORD 'newPassword';

You can leave the psql shell by typing CtrlD or with the command q.

Now you should be able to give pgAdmin a valid password for the DB superuser and it will be happy too. 🙂

Answered By: Anonymous

Related Articles

  • Ubuntu apt-get unable to fetch packages
  • Error 'Map', but got one of type 'Null' flutter web…
  • What is the worst programming language you ever worked with?
  • Homebrew install specific version of formula?
  • Completely uninstall PostgreSQL 9.0.4 from Mac OSX Lion?
  • Docker not able to install git on Ubuntu container
  • How can I start PostgreSQL server on Mac OS X?
  • Postgres could not connect to server
  • Simulate CREATE DATABASE IF NOT EXISTS for PostgreSQL?
  • Postgres password authentication fails
  • postgresql port confusion 5433 or 5432?
  • How to thoroughly purge and reinstall postgresql on ubuntu?
  • The definitive guide to form-based website authentication
  • Can not connect to local PostgreSQL
  • What is the difference between a strongly typed…
  • Install pip in docker
  • psql: FATAL: database "" does not exist
  • How do I login and authenticate to Postgresql after…
  • Psql could not connect to server: No such file or…
  • psql: FATAL: role "postgres" does not exist
  • Save PL/pgSQL output from PostgreSQL to a CSV file
  • How to configure postgresql for the first time?
  • psql: command not found Mac
  • How can I find the product GUID of an installed MSI setup?
  • PostgreSQL: Resetting password of PostgreSQL on Ubuntu
  • How do SO_REUSEADDR and SO_REUSEPORT differ?
  • PostgreSQL psql terminal command
  • Using psql to connect to PostgreSQL in SSL mode
  • Psql list all tables
  • Using aurelia-cli unable to get bootstrap and a…
  • Run a PostgreSQL .sql file using command line arguments
  • How do I query using fields inside the new…
  • C threads corrupting each other
  • How Spring Security Filter Chain works
  • How to UPSERT (MERGE, INSERT ... ON DUPLICATE…
  • Typescript/javascript method being invoked before…
  • How do I resolve `The following packages have unmet…
  • PostgreSQL Crosstab Query
  • PostgreSQL: Why psql can't connect to server?
  • Getting error: Peer authentication failed for user…
  • How to install Maven 3 on Ubuntu…
  • How do I approach solving this problem: Cannot…
  • I forgot the password I entered during postgres installation
  • Error: container has not been made global - how to solve?
  • Apache server keeps crashing, "caught SIGTERM,…
  • Ember build failing
  • PostgreSQL database service
  • Attempt to use Aurelia plugin causing 404 error in browser
  • How to check which PHP extensions have been…
  • Postgresql: Scripting psql execution with password
  • TLS 1.3 server socket with Java 11 and self-signed…
  • Ukkonen's suffix tree algorithm in plain English
  • How can I check if PostgreSQL is installed or not…
  • SPA best practices for authentication and session management
  • How to remove MySQL completely with config and…
  • Why is it that "No HTTP resource was found that…
  • Backup/Restore a dockerized PostgreSQL database
  • Smart way to truncate long strings
  • Postgresql : Connection refused. Check that the…
  • Can't connect to Postgresql on port 5432
  • What are the differences and similarities between…
  • GLYPHICONS - bootstrap icon font hex value
  • "psql: could not connect to server: Connection…
  • PG::ConnectionBad - could not connect to server:…
  • How to speed up insertion performance in PostgreSQL
  • Is the nginx repo the same as the ubuntu 18.04 repo?
  • What is the correct way to split an aurelia app into…
  • SSLError: [SSL: EE_KEY_TOO_SMALL] ee key too small…
  • How connect Postgres to localhost server using…
  • Aurelia customAttribute not working
  • What are the undocumented features and limitations…
  • CSS Input with width: 100% goes outside parent's bound
  • psql: FATAL: Ident authentication failed for user "postgres"
  • Copying PostgreSQL database to another server
  • How to Allow Remote Access to PostgreSQL database
  • Fatal error: Call to undefined function pg_connect()
  • Postgresql -bash: psql: command not found
  • Vagrant error : Failed to mount folders in Linux guest
  • Express Session not persisting after CORS calls
  • How to create User/Database in script for Docker Postgres
  • Insert text with single quotes in PostgreSQL
  • Vue project tests are failing when I added vue-i18n…
  • Using psql how do I list extensions installed in a database?
  • Import SQL dump into PostgreSQL database
  • Vue js vuecli3 application does not work in ie11…
  • PostgreSQL error: Fatal: role "username" does not exist
  • Access denied for user 'root'@'localhost' while…
  • Issue in loading ember app as child application in…
  • PostgreSQL how to see which queries have run
  • What is the easiest way to remove the first…
  • fe_sendauth: no password supplied
  • ERROR 1698 (28000): Access denied for user…
  • Unable to access postgres in docker from web app in…
  • python 3.2 UnicodeEncodeError: 'charmap' codec can't…
  • Ubuntu: OpenJDK 8 - Unable to locate package
  • Allow docker container to connect to a local/host…
  • How to restart Postgresql
  • Start redis-server with config file
  • What is the difference between statically typed and…
  • I lose my data when the container exits

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

How do I delete a local repository in git?

Next Post:

Which MySQL data type to use for storing boolean values

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error