Python 3
SimpleHTTPServer
Programming
Code Conversion
Web Development

What is the Python 3 equivalent of "python -m SimpleHTTPServer"

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

In Python 2, a quick way to serve the current directory over HTTP was python -m SimpleHTTPServer. In Python 3, the equivalent command is python -m http.server, or python3 -m http.server on systems where python still points somewhere else.

The Direct Python 3 Replacement

The simplest form is:

bash
python3 -m http.server

By default, this starts a small HTTP server on port 8000 and serves files from the current working directory.

You can specify a port explicitly:

bash
python3 -m http.server 9000

Then visit http://localhost:9000 in a browser.

The command is meant for convenience: local file sharing, static testing, and quick demos.

Why the Module Name Changed

In Python 3, several modules were reorganized or renamed during the language cleanup from Python 2. SimpleHTTPServer no longer exists as a top-level module in the same way, and its functionality lives under http.server.

That means old instructions like this:

bash
python -m SimpleHTTPServer

need to be updated rather than “fixed” with package installation. The missing module is expected; the replacement is built into Python 3.

Useful Options

A few flags are worth knowing.

To bind to a specific interface:

bash
python3 -m http.server 8000 --bind 127.0.0.1

To serve a specific directory:

bash
python3 -m http.server 8000 --directory ./public

Those options make the server more convenient for local development and safer when you want to limit exposure.

Start It from the Right Directory

Because http.server serves the current working directory by default, the directory you run the command from matters.

bash
cd /path/to/site
python3 -m http.server 8000

If you forget that detail, the server may appear “broken” when it is actually serving a different folder than you expected. For quick local testing, changing into the correct directory first is often clearer than relying on a longer command line.

Open It Deliberately on Shared Networks

If you bind the server to all interfaces, other machines on the same network may be able to access it.

bash
python3 -m http.server 8000 --bind 0.0.0.0

That can be convenient for device testing, but it also means you should think about what directory you are exposing. The server is simple by design, so treat it as a convenience tool, not as a secured file-sharing system.

Know What This Server Is Good For

http.server is excellent for:

  • testing static HTML, CSS, or JavaScript locally
  • sharing files on a trusted local network
  • quickly verifying downloaded build artifacts
  • serving a directory during debugging

It is not a production web server. It lacks the hardening, performance features, and operational behavior you would expect from a real deployment stack.

If you need authentication, robust logging, HTTPS termination, or concurrency control, use a proper server rather than stretching http.server beyond its purpose.

Common Pitfalls

  • Running python -m SimpleHTTPServer under Python 3 and assuming the module should still exist.
  • Forgetting which interpreter python points to on the current machine.
  • Serving the wrong directory because the shell is in an unexpected working directory.
  • Exposing the quick server on a network interface when it was only meant for local use.
  • Treating http.server as a production-ready web server instead of a development convenience tool.

Summary

  • The Python 3 equivalent of python -m SimpleHTTPServer is python3 -m http.server.
  • The default port is 8000, but you can choose another port.
  • 'http.server serves the current directory unless you specify another path.'
  • The module rename is normal Python 2 to 3 evolution, not a missing package issue.
  • Use it for local development and quick file serving, not for production hosting.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.