Using Django's development server without exposing it to the Internet


Django offers a development server to test changes.

One way to test stuff is to install Django and the test server on each development machine and run them locally. This requires either a local database server or a direct connection to the database server.

In my case, I chose to run the development server on my remote server and forward the listening port to my local machine through SSH:

ssh user@myhost.example.com -L 12345:localhost:8000

Once the connection is established, I can type http://127.0.0.1:12345 in my local browser to connect to localhost:8000 as if from the SSH server machine.

Note: I recommend not using hostnames (like 'localhost') in the browser bar since when there's a problem with the connection, modern browsers might try to guess that you wanted to visit www.localhost.com rather than 127.0.0.1