VS Code uses port 5500 by default when you run an HTML file with the Live Server extension

When you use the Live Server extension in VS Code to preview an HTML file, it starts a local web server on port 5500. This is the standard port the extension picks automatically. Your browser then opens to something like http://localhost:5500, and any changes you make to your HTML, CSS, or JavaScript files reload in the browser instantly without you having to refresh manually.

Port 5500 is not a special system port — it is just a number the Live Server developers chose because it is high enough to avoid conflicts with common services and low enough to be easy to remember. If port 5500 is already in use by another program on your machine, Live Server will try the next available port (usually 5501 or 5502) and tell you which one it picked in the VS Code terminal.

Key Takeaways

  • Live Server, the most common VS Code extension for running HTML files, uses port 5500 by default.
  • You access your file at http://localhost:5500 in your browser, where localhost means your own computer.
  • If port 5500 is already in use, Live Server automatically picks the next available port and shows you which one in the terminal.
  • You can change the default port in VS Code settings if you need a different number for a specific reason.
  • Other extensions and tools may use different ports, so check the terminal output to see which port your server actually started on.

How to check which port your server is actually using

When you click "Go Live" in VS Code with Live Server installed, look at the terminal panel at the bottom of the screen. Live Server prints a message that says something like "Server is running at http://localhost:5500". That message tells you the exact port, even if it is not 5500.

You can also look at the bottom right corner of VS Code — Live Server shows the port number there as well. If you do not see a terminal or the message, open the terminal by pressing Ctrl+` (backtick) on Windows or Linux, or Cmd+` on Mac.

Why VS Code does not have a built-in port for HTML files

VS Code itself does not run a web server — it is a text editor. To preview HTML in a browser, you need a separate tool that acts as a server. Live Server is an extension that adds this capability, and it chose port 5500 as its default.

If you use a different tool — like Python's built-in server, Node.js, or a different extension — the port will be different. Python's http.server module defaults to port 8000, for example. The port number depends entirely on what tool you are using, not on VS Code itself.

How to change the port if 5500 does not work for you

If port 5500 is blocked or you want to use a different port, you can change it in VS Code settings. Open the settings by pressing Ctrl+, on Windows or Linux, or Cmd+, on Mac. Search for "Live Server" and look for the setting called "Live Server: Port".

Type the port number you want — for example, 8080 or 3000 — and save. The next time you start Live Server, it will use your chosen port instead. Make sure the port you pick is not already in use by another program. Ports below 1024 usually require special permissions, so pick a number between 1024 and 65535.

What localhost means and why you use it instead of a real web address

Localhost is a special address that means "this computer". When you go to http://localhost:5500, your browser is talking to a web server running on your own machine, not to a server somewhere on the internet. This is why you can preview your HTML file without uploading it anywhere.

The number after the colon — the port — tells your computer which program should handle the request. Port 5500 means "send this to whatever is listening on port 5500", which is Live Server. If you had multiple servers running on different ports, you could switch between them just by changing the port number in the address bar.

Other ways to run HTML files without Live Server

If you do not want to use Live Server, you can run HTML files in other ways. The simplest is to just double-click your HTML file in your file explorer — your default browser will open it directly without needing a port or server. This works fine for static HTML, but you will have to manually refresh the browser each time you change the file.

You can also use Python if it is installed on your computer. Open a terminal in your project folder and run python -m http.server 8000 (or python3 -m http.server 8000 on Mac). This starts a server on port 8000. Then open http://localhost:8000 in your browser. This approach does not auto-reload like Live Server does, but it is useful if you want to test how your site behaves on an actual server.

Why you need a port number at all

A port is like an apartment number on a building. Your computer's IP address (like 127.0.0.1 for localhost) is the building address, and the port is which apartment. Multiple programs can run on the same computer at the same time, each listening on a different port. Without port numbers, your computer would not know which program should handle each request.

When you type http://localhost:5500, you are telling your browser: "Go to my computer (localhost) and talk to whatever is listening on port 5500." If nothing is listening on that port, you get a "connection refused" error. If Live Server is running, it hears the request and sends back your HTML file.

Frequently Asked Questions

What does "connection refused" mean when I try to open localhost:5500?

It means Live Server is not running on that port. Make sure you clicked "Go Live" in VS Code and that the terminal shows the server started successfully. If Live Server is running but you still get the error, check the terminal to see which port it actually started on — it might be 5501 or 5502 if 5500 was in use.

Can I access my HTML file from another computer on my network?

Yes, but you need your computer's IP address instead of localhost. Find your IP address by opening a terminal and typing ipconfig (Windows) or ifconfig (Mac/Linux). Look for the address that starts with 192.168 or 10.0. Then on the other computer, go to http://[your-ip]:5500. Both computers must be on the same network.

Why does Live Server keep changing the port number?

This happens when something else is using port 5500. Another program, a previous Live Server instance that did not fully close, or a firewall rule can block the port. Check the terminal to see which port Live Server actually started on, or restart VS Code and try again. If it keeps happening, change the default port in settings to something less common, like 7777.

Do I need to know the port number to share my HTML file with someone else?

No. The port number only matters while you are developing on your own computer. When you upload your HTML file to a real web server (like for a website), the server handles ports automatically and you just use a normal web address like www.example.com.