Updated:
Localhost Ports: Find the Right Service and Fix Connection Errors
Identify common localhost ports, check the listening process on Windows, macOS or Linux, and distinguish connection refused, 404, HTTPS and Docker networking errors.
When you see http://localhost:PORT, localhost80, or localhost:4173 in a browser or terminal, it is usually not a public website — it is a process on your machine. This guide answers “what is listening on this port?” and lists common defaults.
Paste a full address into the localhost URL parser. For conflict troubleshooting, see localhost port conflicts.
Find the service behind a common port
| Address you see | Typical meaning | Jump |
|---|---|---|
http://localhost / http://localhost:80 / localhost80 | Default HTTP (Apache, Nginx, IIS, Caddy) | #port-80 |
| http://localhost:4173 | Vite preview (vite preview) | #port-4173 |
| http://localhost:4321 | Astro dev server | #port-4321 |
| http://localhost:5173 | Vite dev server (most common) | #port-5173 |
| http://localhost:3000 | Next.js, NestJS, Rails; configurable app ports | #port-3000 |
| http://localhost:8080 | Tomcat, Spring Boot, alternate Apache | #port-8080 |
http://localhost:8081 / exp://localhost:8081 | Expo Metro Bundler | #port-8081 |
| http://localhost:8000 | Django, php -S, FastAPI/Uvicorn | #port-8000 |
mongodb://localhost:27017 | MongoDB | #port-27017 |
redis://localhost:6379 | Redis | #port-6379 |
localhost:80 / localhost80
Meaning: Default HTTP port. Visiting http://localhost uses 80; people also type localhost:80, localhost 80, or localhost80.
Common services: Apache (XAMPP/WAMP/LAMP), Nginx, IIS, Caddy, many PHP stacks.
Check who is listening:
# macOS / Linux
lsof -i :80
If the page fails to load, the service may be stopped or the port occupied — see port conflicts. Also: Apache, Nginx, XAMPP.
localhost:4173 — Vite preview
Meaning: Default port for vite preview (production-build preview).
vs 5173:
| Port | Command | Use |
|---|---|---|
| 5173 | vite / npm run dev | Development (HMR) |
| 4173 | vite preview | Preview built assets |
After npm run build + vite preview, http://localhost:4173 is expected. See Vite on localhost.
localhost:4321 — Astro dev server
Meaning: Astro’s default astro dev port is 4321.
Opening http://localhost:4321 usually means an Astro app is running locally. See Astro.
localhost:5173 — Vite dev server
Meaning: The most common frontend dev port. Vite and many Vite-based tools default to 5173.
http://localhost:5173 ≈ npm run dev is up. See Vite, React + Vite.
localhost:3000
Meaning: A common default in Next.js, NestJS, and Rails. Express and Bun applications can use a developer-selected port; the runtime name alone does not establish port 3000.
Multiple projects often fight over 3000 — change PORT or framework config. See Next.js, NestJS, port conflicts.
localhost:8080
Meaning: Popular alternate HTTP port: Tomcat, Spring Boot (configurable), a second local web server, or Apache moved off 80.
When you open http://localhost:8080, check whether it is Java or a reconfigured Apache/Nginx. See Tomcat, Spring Boot.
Note: queries like http://localhost::8080 (double colon) are typos — use a single colon: http://localhost:8080.
localhost:8081 and exp://localhost:8081
Meaning:
- Browser http://localhost:8081: often Expo Metro or another alternate web port
exp://localhost:8081: Expo / React Native client protocol (not a normal web page)
See Expo local debugging.
localhost:8000
Meaning: Common for Django, php -S localhost:8000, FastAPI (Uvicorn), some Deno apps.
php -S localhost:8000 -t public
Database and cache ports
mongodb://localhost:27017
MongoDB defaults to 27017. Connection strings look like:
mongodb://localhost:27017
mongodb://127.0.0.1:27017/mydb
This is a client URI (mongosh, Compass, drivers), not a browser page. See MongoDB locally.
redis://localhost:6379
Redis defaults to 6379:
redis://localhost:6379
See Redis locally.
Other database ports
| Port | Service | Guide |
|---|---|---|
| 3306 | MySQL / MariaDB | MySQL, MariaDB |
| 5432 | PostgreSQL | PostgreSQL |
Web & frontend ports (full table)
| Port | Typical use | Example |
|---|---|---|
| 80 | Apache, Nginx, IIS default HTTP | http://localhost |
| 443 | HTTPS | https://localhost |
| 3000 | Next.js, NestJS, Rails, configured apps | http://localhost:3000 |
| 4173 | Vite preview (vite preview) | http://localhost:4173 |
| 4200 | Angular CLI (ng serve) | http://localhost:4200 |
| 4321 | Astro dev server | http://localhost:4321 |
| 5000 | Flask default | http://localhost:5000 |
| 5173 | Vite dev server | http://localhost:5173 |
| 8000 | Django, php -S, Uvicorn | http://localhost:8000 |
| 8080 | Tomcat, Spring Boot, alternate web | http://localhost:8080 |
| 8081 | Expo Metro, alternate web | http://localhost:8081 |
| 8888 | MAMP default, Jupyter, … | http://localhost:8888 |
localhost:8888 — MAMP Apache
MAMP on macOS uses 8888 for Apache by default; its Nginx and database ports are separate settings. Check MAMP’s port settings rather than assuming the web server is on 80. If your configured application is under /moodle, its URL might be http://localhost:8888/moodle/; keep that port in Moodle’s wwwroot too. Other applications can also use 8888, so identify the listening process. See MAMP setup.
Other common ports
| Port | Use |
|---|---|
| 1337 | Strapi default |
| 19000 | Legacy Expo Dev Tools |
| 54321 | Supabase local CLI (API gateway, …) |
| 9000 | PHP-FPM (FastCGI; usually not opened in a browser) |
Diagnose an address that will not open
A familiar port is a clue, not proof of which application is listening. Another app can use the same port. Start from the URL printed by your process and the browser’s exact error.
| What you see | What to check next |
|---|---|
ERR_CONNECTION_REFUSED | Is a process listening on this address and port? Start or inspect it before changing browser settings |
Address already in use / EADDRINUSE | Identify the listener, then choose whether to change the app port or stop that known process |
| HTTP 404 | An HTTP server answered. Check its project directory, document root, and requested path |
| TLS / SSL protocol error | Check whether the service expects http:// or has actually been configured for HTTPS |
| App works on the computer but not a phone | Use the computer’s LAN address; the phone’s localhost is the phone |
| App works on the host but not in Docker | Use the address appropriate to the container network, not the host’s localhost |
For example, check a listener on 5173 with the command for your OS:
# macOS
lsof -nP -iTCP:5173 -sTCP:LISTEN
# Linux
ss -ltnp 'sport = :5173'
# Windows PowerShell
Get-NetTCPConnection -LocalPort 5173 -State Listen
Look at the process and local address, not only the port. A listener on 127.0.0.1 is IPv4 loopback; one on ::1 is IPv6 loopback. If localhost resolves to an address the app does not bind to, compare with the explicitly configured address. An absence of listener results means the next step is checking startup logs.
For HTTP services, curl -I http://127.0.0.1:5173/ can help determine whether a server responds. Some apps reject HEAD requests; an HTTP error response still proves a server answered. Use mongosh for MongoDB and redis-cli for Redis instead of an HTTP probe.
See Vite’s dev/preview checklist, Docker networking, and the port conflict guide.
How to see who owns a port
- macOS / Linux:
lsof -i :5173orss -tlnp | grep 5173 - Windows:
netstat -ano | findstr :5173
Freeing ports, changing binds, Docker conflicts: port-conflicts.
FAQ
Q: Difference between localhost:80 and localhost?
None for HTTP — omitting the port means 80.
Q: Why does localhost:4173 show up?
Usually Vite preview was started. Stop that process and the URL goes away.
Q: Port opens but the page is blank?
Service may not be running, may use another port, or may not bind to the interface you expect. Check with lsof / netstat.
Summary
Memorize the high-frequency set: 80 (default site), 5173 (Vite dev), 4173 (Vite preview), 4321 (Astro), 3000 (Node stacks), 8080 (Java / alternate web), 8000 (Django/PHP), 27017 (MongoDB), 6379 (Redis).