How to Use Python ‘SimpleHTTPServer’ to Create Webserver or Serve Files Instantly

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Thilina Uvindasiri

I'm a BSc Special (Hons) graduate in Information Technology and works as an Engineer-Systems. Love to work, explore and research Linux and play rugby as a hobby.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

18 Responses

  1. Obaidulla says:

    Thanks a lot and like to see more python solution.

  2. Ahmad Amr says:


    Thanks, but do you know how to keep it running in the background? Whenever I log out of the ssh session, it cannot server again and gives 404 error!!

    • Ravi Saive says:

      Just add & string at the end of the command to keep the process running in background even after you logout from your SSH session. For example,

      # python –m SimpleHTTPServer &
      • Thilina Uvindasiri says:

        I don’t think that will work. If you ran the command by background and if you exit the terminal, it will get disconnected. Use below command instead. It will not disconnect the SimpleHTTPServer after you logout of the terminal.

        nohup python -m SimpleHTTPServer 9999 &

        Hope this will be useful

  3. Hi Uwe,
    Thanx for the correction :)

  4. Uwe says:

    Hi, Thilina, there is a typo under point 4. : “(In my case, /x01/tecmint/)”. That should be “(In my case, /x01/)” as can be seen in the picture below. Best, Uwe

  5. AlexSan says:

    Very helpful. Thanks :)

  6. Hi Setevoy,
    We’ll look in to your request and do the needful in the future. Thanx :)

  7. Hi Kumar, Thanx very much. :)

  8. setevoy says:

    WIll be nice to see same useful article about CGIHTTPServer.

  9. Parijatha Kumar says:

    Nice article. I know python-3 has a simple inbuilt http server and I have seen it’s uses in django while testing. However, using this technique for serving files on an ad hoc basis in your LAN in your office or home is one of the easiest ways. When all you want is to send a few files to other machines in your LAN, you need not worry about the OS of the other machines or how to configure SAMBA, NFS, SSH etc cause python’s built in http sever makes it trivial. You can even share files like this to your mobiles phones as well.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.