This space is available for advertisement. Please contact us if interested.
Advertise with us
django-app hosting   2   10446
Python Tip 1: Accessing localhost Django webserver over the Internet

We use Django development webserver to test our application on localhost.

We can start the development webserver with below command:

$ python runserver

Now one problem we face with this approach is that we can access/browse the project over the browser only in the local network to which our system is connected.

What if you want to show your project to someone at another location, in another city over the Internet?

How would you generate a public URL for your localhost webserver?  

For such situations, there is one software available. ngrok.

How to use it:

- Download the ngrok from its download page .

django app on public url ngrok

-  Follow the documentation to unzip the downloaded content and to add the authentication token.

unzip /path/to/
./ngrok authtoken 2rMfGz4YvhuzyQUoRAE2ZAWDD4TLAer9Tgzpk85xmsVu

- Go to your project directory and activate your virtual environment.

-  Now start your Django development server at port lets say 8080.

- You can access your project on localhost:8080. We will generate a public URL for this localhost URL by creating a tunnel using ngrok.

- Go to the directory where you unzipped ngrok and run below command.

./ngrok http 8080
- You will see something like this:

django app on public url ngrok

- Now you can access your project over the public address  .

-  You can access the web interface on to see which URL got how many hits.

accessing django app publicly

  You can host your Django App for free on PythonAnyWhere server.

django-app hosting   2   10446

Related Articles:
AWS EC2 Vs PythonAnyWhere Vs DigitalOcean for hosting Django application
This article list out the differences between three major options to deploy Django application, We are briefly comparing the digital ocean, pythonAnyWhere, and AWS EC2 to host the Django application here, AWS EC2 Vs PythonAnyWhere for hosting Django application, hosting Django application for free on AWS EC2, Hosting Django application for free on PythonAnyWhere, comparing EC2 and Pythonanywhere and DigitalOcean...
How to upgrade to paid account on PythonAnyWhere
Which is the best server for hosting Django Apps, Best hosting provider for Django Apps, Cheapest Django Hosting, PythonAnyWhere Reviews, Django Hosting,...
Automatically updating Django website hosted on PythonAnyWhere server with every git push
How to automate the process of updating website hosted on python any where server everytime you commit and push code to git repository....
How to setup Django app on EC2 instance (AWS)
Step by step guide on hosting Django application on AWS ec2 instance, How to host the Django app on AWS ec2 instance from scratch, Django on EC2, Django app hosting on AWS, Free hosting of Django App...

2 thoughts on 'Python Tip 1: Accessing Localhost Django Webserver Over The Internet'
Gaurav Bhatt :
Nice. Interesting way to host for temporary basis.

Rohit Soni :
great article saved a lot of time

Leave a comment:

*All Fields are mandatory. **Email Id will not be published publicly.

DigitalOcean Referral Badge

Get a .COM for just $5.98!

© 2021-2022 Python Circle   Contact   Sponsor   Archive   Sitemap   Partner Sites: PythonSnippets.Dev  99Dev.Tools