Ubuntu 18 Start simple web host with python on localhost

Python is part of Ubuntu so you can use python to start: SimpleHTTPServer(Since Ubuntu 16.04 Python 3 is included by default). This is really quick and out of box solution to run web server on your Ubuntu 18 machine.

How to use it

You can start it simply by command: python -m SimpleHTTPServer (starting at port 8000) or by providing a port. You have to in the folder that you want to be served. So open your terminal by CTRL+ALT+T:

cd \home\folder\site
python -m http.server 8080

or : python3 -m http.server 8080 - depending on your python settings

If you have python 2 than you can run:

cd \home\folder\site
python -m SimpleHTTPServer 8080


python -m SimpleHTTPServer 8080
Serving HTTP on port 8080 ...

Once started you can access all the files that you serve to address:


Run the server after close of terminal

If you stop your session in terminal the server will stop too. In order to run it even when terminal is closed use nohup - no hung up command:

nohup python -m http.server 8080 &

Check Python version

In order to check your python version use:

python --version
python -V


python --version
Python 2.7.6

More information:

Simple HTTP request handler

Share Tweet Send
You've successfully subscribed to SoftHints - Python, Data Science and Linux Tutorials
Great! Next, complete checkout for full access to SoftHints - Python, Data Science and Linux Tutorials
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.