Fix: psql: error: connection to server at localhost (::1) port 5432 failed: FATAL: database does not exist


Below are some of the steps you can try to resolve this issue.


Step 1: Make sure the database exists

# psql -h localhost -p 5432 -U db-username -d db-database

Step 2: Check the list of Databases that exits

# psql -h localhost -p 5432 -U db-username -l

This will provide you with the list of all the databases, which will help you to know if it does not exist or you have misspelled it.

psql list of all databases

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap