Home / Localhost / localhost:5432

localhost:5432: PostgreSQL connection fixes

Port 5432 is PostgreSQL’s default port. Connect with psql, check it with pg_isready and fix connection refused and password errors.

A database client connects to localhost:5432, which is port 5432 on your computer, where PostgreSQL is running

Not a web pagePort 5432 belongs to PostgreSQL. Connect with psql or a database tool, not a browser.

localhost:5432 is where PostgreSQL listens by default. It is a database port, not a web page, so connect with psql or a database tool.

What runs on localhost:5432

Commands to start and test port 5432

Connect with psql
psql -h localhost -p 5432 -U postgres
Check that the server accepts connections
pg_isready -h localhost -p 5432
Start it (Linux)
sudo systemctl start postgresql
Docker: run a test database
docker run -p 5432:5432 -e POSTGRES_PASSWORD=change-me postgres:16

Find what is using port 5432

Run these in a terminal on your computer. Nothing is sent to this site.

If localhost:5432 will not open

connection refused
PostgreSQL is not running or listens on another port. Start it and check the port with the tool below.
password authentication failed for user
Wrong password, or pg_hba.conf asks for a different login method. Reset the password with ALTER USER inside psql.
role “…” does not exist
Create the role, or connect as the postgres user first.
Port 5432 is already taken
An older PostgreSQL is running. Map yours to another port, such as -p 5433:5432. See the Docker Compose PostgreSQL generator.

Other ports like 5432

PortUsually used by
localhost:3306MySQL, MariaDB
localhost:27017MongoDB
localhost:6379Redis
localhost:11211Memcached
localhost:1433Microsoft SQL Server
localhost:5984CouchDB
localhost:8983Apache Solr

Questions about localhost:5432

What is port 5432?
The default port of PostgreSQL.
Why does psql say connection refused?
Nothing is listening on that port. Start PostgreSQL, or connect to the port it actually uses.
Is localhost:5432 safe?
Yes while it listens only on 127.0.0.1. If you open this port to a network, use a strong password, allow only trusted addresses in the firewall, and encrypt the connection. Do not expose a database port to the internet.
Can I use a different port instead of 5432?
Yes. Pick a free port above 1024, set it in the program, and open that number instead. If other programs connect to this port, change it there as well.
How do I check what is using port 5432?
Use the port checker on this page. It shows the command for Windows, macOS and Linux and does not send anything to this site.

Updated 2026-10-03

Free tools that help

Related pages