Start a Web Server With One Terminal Command on OS X

I've searched for this three times this week, so I figured I'd better make sure I have a copy of it:

python -m SimpleHTTPServer 8000

Navigate to the project directory in the terminal and do that command. Then http://localhost:8000 will server up that directory (as in, it's `index.html` file).


  1. User Avatar
    Craig Morrison
    Permalink to comment#

    It can be very useful to spin up a quick server.
    php -S localhost:8000 also works in recent versions.

  2. User Avatar
    Rhys Lloyd
    Permalink to comment#

    Requires installation, but with Node:

    npm i -g http-server

    Once installed, you can run from any directory:

    • User Avatar
      Permalink to comment#

      I use “http-server” regularly. It is simpler and easy to remember.

    • User Avatar
      samar taj shaikh
      Permalink to comment#

      okay i did as you commented in the terminal of my linux OS –

      $ http-server

      but i am getting error as-
      “http-server: command not found”

    • User Avatar
      Permalink to comment#

      Oh man. Where has this been all my life. This has been an immense time-saver for me, being able to spin up a standalone server for any given directory, pass some parameters — boom, local server to test on. Thanks for posting this!

  3. User Avatar
    Permalink to comment#

    @samar you need to install http-server first:

    npm i -g http-server

    You need npm to install http-server, and to run that npm command you need npm, and to have npm installed you need Node :)

    Install Node
    Install npm
    install http-server

    All 3 of them can be installed with only few lines…

    So google them all.

Leave a Comment

Posting Code!

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.