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.
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
- PostgreSQL servers (default port 5432)
- Docker containers started with
-p 5432:5432 - Postgres.app on macOS, EDB installer on Windows
Commands to start and test port 5432
psql -h localhost -p 5432 -U postgrespg_isready -h localhost -p 5432sudo systemctl start postgresqldocker run -p 5432:5432 -e POSTGRES_PASSWORD=change-me postgres:16Find 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 USERinside 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
| Port | Usually used by |
|---|---|
| localhost:3306 | MySQL, MariaDB |
| localhost:27017 | MongoDB |
| localhost:6379 | Redis |
| localhost:11211 | Memcached |
| localhost:1433 | Microsoft SQL Server |
| localhost:5984 | CouchDB |
| localhost:8983 | Apache 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.
Free tools that help
- Common ports listSearch a list of common TCP and UDP port numbers: SSH 22, HTTP 80, HTTPS 443, MySQL 3306, PostgreSQL 5432 and more, with dev server ports.