A Python HTTP server on Windows is a handy way to preview web files in a browser or share files with another device on your local network. Python includes a small server module, so you can start one from PowerShell or Command Prompt without installing a separate web server.
This server is intended for temporary, local use. It works well for testing static pages and sharing a folder on a trusted network, but it isn’t a secure way to host a public website. Here’s how to start it, choose who can connect, and shut it down safely.
Before you start a Python HTTP server on Windows
First, check whether Python is available. Open PowerShell or Command Prompt and run:
py –version
If Windows displays a Python version, the Python launcher is ready. If the command isn’t recognized, install Python from its official distribution and make sure the Python launcher is included. Close and reopen the terminal after installation, then check again.
Some systems use python instead of py. You can check that command too:
python –version
Use whichever command works in the steps below. This guide uses py as the example. You’ll also need to choose a folder to serve. Select one containing only the files you intend to make available. The server can expose the contents of its current working directory, so don’t start it from a folder containing private documents.
Start the server on your own computer
Open a terminal in the folder you want to share. One simple method is to open the folder in File Explorer, select the address bar, type powershell, and press Enter. PowerShell opens with that folder as its working directory.
Start the server on port 8000 and bind it only to your computer:
py -m http.server 8000 –bind 127.0.0.1
Python should indicate that it’s serving HTTP on port 8000. Keep the terminal window open while you use the server. In a browser on the same PC, visit:
http://127.0.0.1:8000
You can also use http://localhost:8000. The browser should show a directory listing or open a default page such as index.html if the folder contains one. Select a listed file to view or download it.
The address 127.0.0.1 means “this computer.” Binding the server to that address limits connections to the same PC, which is a sensible default for previewing a site or checking files. The server doesn’t copy or move anything; it makes files in the selected folder available over HTTP while it’s running.
Make the server available to another device
To connect from a phone or another computer on your home network, the server must listen on the PC’s network interfaces rather than only on its loopback address. Stop the current server with Ctrl+C, then start it again:
py -m http.server 8000 –bind 0.0.0.0
This makes the server listen on available IPv4 interfaces. It doesn’t make the server reachable from everywhere on the internet by itself, but devices that can reach your PC on the network may be able to connect. Use this setting only when you intend to share the folder and only on a network you trust.
Find the PC’s local IPv4 address by running:
ipconfig
Look for the IPv4 address under the active Wi-Fi or Ethernet adapter. It often begins with a private-network range such as 192.168 or 10, though the exact address varies. On the other device, open a browser and enter that address followed by the port. For example:
http://192.168.1.25:8000
Replace the sample address with the one shown by ipconfig. Both devices generally need to be on the same local network. Guest Wi-Fi, client isolation, a VPN, or a firewall policy can prevent devices from reaching each other even when they use the same router.
Windows Firewall may ask whether to allow Python to communicate on a network. Allow access only on a private network you trust, and avoid allowing it on public networks. If there’s no prompt and another device can’t connect, review the firewall settings before changing anything. Don’t create a router port-forwarding rule for this temporary server, since that could expose it beyond your local network.
What this built-in server can and can’t do
The command uses Python’s built-in http.server module. It serves files over HTTP and is convenient for basic development tasks, such as checking how a static HTML page looks in a browser. It can also provide a quick way to retrieve a file from another device on a trusted network.
It isn’t a full web-hosting platform. The basic server doesn’t provide user accounts, encrypted HTTPS connections, or a safe publishing workflow. Anyone who can reach it may be able to browse and request files in the served directory. Don’t use it to share confidential files, host a public site, or replace a properly configured production server.
The standard directory listing also doesn’t accept uploads. A browser can request or download files, but this command alone isn’t a two-way file-sharing service. For sensitive transfers or ongoing collaboration, use a service designed for that purpose with appropriate access controls.
Choose a different folder or port
To serve a folder without changing the terminal’s current location, provide its path with the –directory option:
py -m http.server 8000 –bind 127.0.0.1 –directory “C:UsersAlexDocumentssite-preview”
Replace the sample path with the folder you want to serve. Keep the quotation marks if the path contains spaces. Don’t point the command at a broad location, such as your entire user profile, unless you intend to make all of its contents available.
If port 8000 is already in use, choose another unused port, such as 8080:
py -m http.server 8080 –bind 127.0.0.1
Then visit http://127.0.0.1:8080. If you’d rather identify the program already using the original port, follow this guide to find the process that owns a port on Windows.
Fix common connection problems
The browser says it can’t connect
Check that the server is still running and that the terminal hasn’t been closed. Confirm that the browser address uses the same port shown in the command. For a same-PC test, use 127.0.0.1 or localhost. For another device, use the PC’s current local IPv4 address, not localhost, which refers to the device running the browser.
Another device can’t see the folder
Confirm that you started the server with –bind 0.0.0.0, and check that the second device is on a network that can reach the PC. Verify the PC’s active IPv4 address again because it can change after reconnecting to Wi-Fi. If the firewall blocks the connection, allow the server only on a trusted private network. Avoid disabling the firewall entirely.
Python reports that the address is already in use
Another program may be listening on that port, or a previous server may still be running in another terminal. Stop any server you started with Ctrl+C. Otherwise, try a different port and update the browser address to match it. The linked port-owner guide explains how to inspect processes using a Windows port.
The browser shows the wrong files
The server uses the terminal’s current folder unless you provide –directory. Check the folder path in File Explorer, then start the server from that folder or specify the full path in the command. A directory listing reflects the files available there; it isn’t a separate copy that updates independently.
Stop the server when you’re finished
Return to the terminal window running the server and press Ctrl+C. The server process will stop, and the browser will no longer be able to load files from it. Stop the server before closing the terminal, especially if you used the network-facing 0.0.0.0 binding.
For a quick preview or temporary transfer on a trusted network, Python’s built-in server is convenient because it takes only a short command. Keep the served folder small and intentional, use the loopback address when you don’t need another device to connect, and stop the process as soon as the task is done.
