Blog available for sell
This blog is available for sale. Please 'contact us' if interested.
Advertise with us
django-app hosting   2   15074
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 manage.py 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.zip
./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 http://9f134cf4.ngrok.io  .

-  You can access the web interface on http://127.0.0.1:4040 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   15074
2 comments on 'Python Tip 1: Accessing Localhost Django Webserver Over The Internet'
Login to comment

Gaurav Bhatt Aug. 27, 2018, 7:29 a.m.
Nice. Interesting way to host for temporary basis.
Rohit Soni April 3, 2020, 8:32 a.m.
great article saved a lot of time

Related Articles:
How to host Django application on DigitalOcean server using Gunicorn, Supervisor, and NGINX
hosting Django application on DigitalOcean Server with custom Domain. Using WSGI server to host the Django application. Hosting Django application with Gunicorn, Supervisor, NGINX. Service static and media files of Django application using NGINX. Using Godaddy Domain to server traffic of Django application. Production deployment of Django applications....
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...
Using a custom domain for Django app hosted on AWS EC2
Using a custom domain for Django app hosted on AWS EC2, GoDaddy DNS with EC2 instance, Django App on EC2 with GoDaddy DNS, Using domain name in Nginx and EC2, Elastic IP and DNS on EC2...
AWS EC2 Vs PythonAnyWhere for hosting Django application
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...
DigitalOcean Referral Badge

© 2024-2025 Python Circle   Contact   Sponsor   Archive   Sitemap