Learn how to make Django App Publicly Accessible With Ngrok following this short article
Sometimes when developing our Django application, we need to make it publicly accessible or use https, for example when testing OAuth authentication sometimes https is enforced, or when testing Shopify webhooks (where the request is executed on Shopify server, so we need to make it publicly available), or simply when we want to share it with a friend without deploying it live.
To achieve it We can use ngrok to redirect what you are running on localhost to publicly available ngrok URL. Let’s get started.
on mac, we can install it simply with brew.
brew cask install ngrok
For windows we can download it from here.
o start ngrok we simply type “ngrok http [port]“, in our case we use port 8000, because it’s the default Django development server port.
ngrok http 8000
you will see the ngrok screen, and your ngrok URL, in my case it’s http://5cedabab7730.ngrok.io, you also have https connection available.
Now go to settings.py and add 5cedabab7730.ngrok.io to ALLOWED_HOSTS. Run your Django development server.
python manage.py runserver
Now your Django App is available to the world under https://5cedabab7730.ngrok.io you can test external APIs, authentications, or share what you working on with your friends.