Share localhost / Django
Share a Django dev server at a public URL
python manage.py runserver listens on 127.0.0.1:8000, and whk share 8000 gives it an HTTPS link. Pages load with your settings untouched; forms need one line, because Django compares each POST's origin with the host it sees.
# terminal 1: the dev server
python manage.py runserver
# terminal 2: the link
whk share 8000The link is https://<name>.sharehooks.cc and works until you press Ctrl-C. No whk yet? Install it and log in, which takes a minute.
Django at a glance
- Dev server
python manage.py runserver, port 8000- Share it
whk share 8000- Setting to add
CSRF_TRUSTED_ORIGINS = ["https://*.sharehooks.cc"]insettings.py.ALLOWED_HOSTScan stay as it is.- Without it
- Pages load, but every form POST answers
403 ForbiddenwithOrigin checking failed - https://<name>.sharehooks.cc does not match any trusted origins. - Hot reload
runserverreloads Python code as it changes, so visitors get your edit on their next request. It does not refresh the browser.- URLs and cookies
build_absolute_uri()returnshttp://localhost:8000/...unlessUSE_X_FORWARDED_HOSTandSECURE_PROXY_SSL_HEADERare set, together withALLOWED_HOSTS. Cookie defaults work.
Your dev server gets each request with Host: localhost:8000; the public name travels in X-Forwarded-Host, with X-Forwarded-Proto: https. What your server sees has the rest.
ALLOWED_HOSTS is already satisfied
With DEBUG = True and an empty ALLOWED_HOSTS, Django validates the host against ['.localhost', '127.0.0.1', '[::1]']. The link sends Host: localhost:8000, so a fresh project serves its pages through a share with no change.
The error most tunnel guides are about, Invalid HTTP_HOST header: '<name>'. You may need to add '<name>' to ALLOWED_HOSTS. with status 400, belongs to tunnels that pass the public name as Host. You will only meet it here if you turn on USE_X_FORWARDED_HOST, which is covered below.
Trust the preview's origin for forms
For a POST that carries an Origin header, Django's CSRF protection requires it to match the origin of the host it sees. The browser sends Origin: https://<name>.sharehooks.cc; Django sees http://localhost:8000. The form answers 403 with the reason Origin checking failed - https://<name>.sharehooks.cc does not match any trusted origins.
List the origin in CSRF_TRUSTED_ORIGINS. Values need their scheme, and * stands for a subdomain:
settings.py
# Previews opened with whk share
CSRF_TRUSTED_ORIGINS = ["https://*.sharehooks.cc"]That one setting is enough for login forms, the admin and your own views. The wildcard trusts every preview name, other people's included; with a reserved name, list only yours: ["https://acme.sharehooks.cc"].
Absolute URLs behind the link
request.build_absolute_uri() and request.get_host() go by the Host header, so they say http://localhost:8000. Relative links and redirects are unaffected, and a redirect to that address comes back to the link. If you need the public address in an email, a sitemap or an OAuth callback, tell Django to read the forwarded headers:
settings.py
# Only while sharing: the link sets these headers on every request
USE_X_FORWARDED_HOST = True
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
ALLOWED_HOSTS = [".sharehooks.cc", "localhost", "127.0.0.1"]Set all three together. USE_X_FORWARDED_HOST alone makes every request fail the host check with status 400, since the forwarded name is then validated against ALLOWED_HOSTS; SECURE_PROXY_SSL_HEADER alone leaves the CSRF check comparing against https://localhost:8000. With the three in place Django sees the public origin itself, and forms pass without CSRF_TRUSTED_ORIGINS. Take them out again for direct local use: Django's docs warn against trusting these headers when no proxy sets them.
Static files, cookies and the debug page
runserver serves static files itself when DEBUG is on and django.contrib.staticfiles is installed, on the same port, so styles and scripts come through the link. The session and CSRF cookies are set without a domain and without Secure by default, which works on the link as it does locally.
DEBUG = True also means a visitor who triggers an error sees Django's debug page, with settings and local variables. Share what you would show, or put a password on the share.
Django questions
Add the tunnel's origin, scheme included, to CSRF_TRUSTED_ORIGINS. For whk share that is CSRF_TRUSTED_ORIGINS = ["https://*.sharehooks.cc"]. The 403 page's reason is "Origin checking failed": the form's Origin header is the public address while Django sees localhost.
Not with whk share. Your dev server gets Host: localhost:8000, which Django's development default accepts. Add .sharehooks.cc only if you enable USE_X_FORWARDED_HOST, because Django then validates the forwarded host instead.
The server reloads your Python code when files change, so the next request a visitor makes runs the new code. Django does not push a refresh to the browser; visitors reload the page themselves.
8000 on 127.0.0.1 by default. python manage.py runserver 7000 picks another port; share the same number with whk share 7000.
Sources
The Django settings and messages on this page are from the official documentation and source for Django 6.1, read on 12 November 2026. What the link does to a request is from the whk share docs.
Other frameworks
Send someone your Django app
Sign up free, install the CLI and run whk share 8000.
No credit card