http.server Verified current stable Not installed? Cloud Infrastructure

Http.server / Start Http Server Port 8000

Start Http Server Port 8000

Starts a simple HTTP server on port 8000.

$
Terminal
python -m http.server

When To Use

When testing web applications or serving files locally on a quick basis.

Pro Tip

Use the `--bind` option to specify an IP address for access control.

Anatomy of Output

Understanding the result

Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ... Server Status

Indicates server status and accessibility.

127.0.0.1 - - [date time] "GET / HTTP/1.1" 200 - Access Log

Shows request logged by the server.

Troubleshooting

Common pitfalls

OSError: [Errno 98] Address already in use

Solution: Ensure no other services are using port 8000.

PermissionError: [Errno 13] Permission denied

Solution: Run with appropriate privileges or choose a different port.

RuntimeError: Threaded servers not supported on this platform

Solution: Use a compatible system for threaded operation.

Command Breakdown

What each part is doing

python
Base Command
The executable that performs this operation. Here it runs Http.server before the shell applies any redirect operators.
-m
Command Option
Tool-specific option used by this command invocation.

Alternative Approaches

Comparable commands in other tools

Alternative cloud infrastructure tools for the same job.