How do I fix the "Database Does Not Exist" error when connecting to PostgreSQL?

A Database Does Not Exist error like the following occurs when you try to connect to a database doesn’t exist in your specified cluster or to the wrong cluster:

psql: FATAL:  database "defaultdb" does not exist

If you are getting this error, first verify that you are using the correct hostname to connect by following How to Connect to PostgreSQL Database Clusters. Then, verify that you’ve created the database in your cluster of choice by following How to Manage PostgreSQL Users and Databases in a Database Cluster.

Verify the hostname and check your local machine for DNS resolution issues.
Use the command CREATE EXTENSION vector; instead of pgvector.
Add the –no-role-passwords flag to the pg_dumpall command.