Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»General Articles»FATAL: Ident authentication failed for user "postgres"

    FATAL: Ident authentication failed for user "postgres"

    RahulBy RahulFebruary 9, 20151 Min Read

    While configuring a new hosting setup with ROR and PostgreSQL. I faced following issue when application tried to connect postgres database server.

    Error:-

    FATAL: Ident authentication failed for user “postgres”

    Solution:-

    First I set the the password for postgres user in PostgreSQL using following commands.

    $ sudo -u postgres psql
    

    Now set the password using following command.

    postgres=# password
    

    Let’s create a new user account for your application using following command. Also crate a database with ownership of that account.

    postgres=# create user "myappusr" with password '_password_';
    postgres=# create database "myapp_development" owner "myappusr";
    

    Now edit pg_hba postgresql configuration file and update configuration. By default PostgreSQL uses IDENT-based authentication. You need to allow username and password based authentication. IDENT will never allow you to login via -U and -W options.

    # vim /var/lib/pgsql/9.4/data/pg_hba.conf
    
    local   all             postgres                                trust
    local   all             myapp_usr                               trust
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            trust
    # IPv6 local connections:
    #host    all             all             ::1/128                 trust
    
    ident postgres
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Setup NTP Server on CentOS/RHEL 7/6 and Fedora 30/29
    Next Article How to Install CSF (ConfigServer & Security Firewall) on cPanel

    Related Posts

    Filesystem Hierarchy Structure (FHS) in Linux

    Updated:July 1, 20222 Mins Read

    What is CPU? – Definition, Types and Parts

    3 Mins Read

    How to Install Ionic Framework on Ubuntu 22.04

    3 Mins Read

    What is the /etc/hosts file in Linux

    Updated:June 27, 20222 Mins Read

    Creating DMARC Record for Your Domain

    Updated:June 29, 20223 Mins Read

    What is Computer Hardware?

    4 Mins Read

    2 Comments

    1. Ron on May 3, 2017 8:03 pm

      The second command – to change the password – does not work at all.

      Reply
    2. Bolo on April 27, 2017 12:14 pm

      Really? Trust? This is very dangerous. Even when database server listen on localhost.
      Better replace trust with md5.

      This is from documentation – “Allow the connection unconditionally. This method allows anyone that can connect to the PostgreSQL database server to login as any PostgreSQL user they wish, without the need for a password or any other authentication. See Section 19.3.1 for details.”

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • Filesystem Hierarchy Structure (FHS) in Linux
    • How to accept user input in Python
    • What is difference between var, let and const in JavaScript?
    • What is CPU? – Definition, Types and Parts
    • What is the /etc/aliases file
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.