What is Captive portal?
A captive portal is the page that pops up when you join Wi-Fi in a hotel, airport, cafe or train. The Wi-Fi itself is open, but a gateway blocks the internet until you accept terms, enter a room number or pay.
Your phone notices the portal by fetching a small test page right after joining. If the answer is a redirect instead of the expected reply, it opens a sign-in window. Newer networks can announce the portal directly through DHCP and a small JSON API, which avoids the redirect tricks.
Think of it like this. A captive portal is like a building with an open front door and a reception desk just inside. You can walk into the lobby (join the Wi-Fi), but the lifts stay locked until you sign the visitor book. The phone's test request is like trying the lift button to see if it works.
Step by step
Normal
5 stepsA phone joins open hotel Wi-Fi, its test request is redirected, the guest signs in and the internet opens.
Normal
5 stepsA phone joins open hotel Wi-Fi, its test request is redirected, the guest signs in and the internet opens.
- 1
Join and get an address
Open Wi-Fi and DHCP
The hotel network has no Wi-Fi password, so joining is instant. DHCP gives the phone an address. The gateway lets through DHCP, DNS and the login page, and blocks everything else.
- 2
Connectivity check
The test request is redirected
Right after joining, phones and laptops fetch a known plain HTTP test page. The gateway intercepts it and answers with a 302 redirect to the login page. Getting anything but the expected answer tells the phone there is a portal.
- 3
Login page
The sign-in window opens
The phone opens a small browser window on the redirect address. The login page itself is a normal HTTPS site.
- 4
Sign in
Room number and surname
The guest submits the form. The portal tells the gateway to allow this phone's IP and MAC address for a set time.
- 5
Internet opens
The test passes
The phone repeats its test. This time the real server answers 204 No Content, so the phone marks the Wi-Fi as connected and apps start syncing.
Portal API
4 stepsThe modern way: the network names its portal in DHCP, and the phone asks a small JSON API instead of guessing.
Portal API
4 stepsThe modern way: the network names its portal in DHCP, and the phone asks a small JSON API instead of guessing.
- 1
DHCP names the portal
Option 114
RFC 8910 adds a DHCP option (114 for IPv4, 103 for DHCPv6, and an IPv6 router advertisement option) that carries the portal's API address.
- 2
Ask the API
captive: true
The phone fetches the API over HTTPS with Accept: application/captive+json. The JSON says whether the device is held back and where to sign in, as RFC 8908 describes.
- 3
Sign in
Same login page
The user signs in on the portal page as before. No redirect tricks are needed, so nothing breaks.
- 4
Ask again
captive: false
The API now says captive is false and how many seconds remain. Phones that support it can show a timer and warn before the session ends.
HTTPS fails
4 stepsBefore signing in, Mateo opens an https:// news site and gets a security warning instead of the login page.
HTTPS fails
4 stepsBefore signing in, Mateo opens an https:// news site and gets a security warning instead of the login page.
- 1
Open a secure site
https://www.example.com
Mateo dismissed the sign-in window and opened his news site, which uses HTTPS like nearly every site today.
- 2
The gateway cuts in
Wrong certificate
The gateway intercepts the connection, but it cannot show a valid certificate for www.example.com. It can only show one for its own name.
- 3
Browser refuses
Your connection is not private
The browser sees the name mismatch and stops, as it should. HSTS sites do not even offer a way to continue. Some gateways just drop HTTPS instead, so the page spins until it times out.
- 4
The way out
Use the sign-in prompt
Tap the Wi-Fi sign-in notice, or type any plain http:// address so the gateway can redirect it. After signing in, HTTPS sites work normally.
Myths and mix-ups
- The open hotel Wi-Fi is not encrypted on the air just because it has a login page; use HTTPS or a VPN.
- The certificate warning before login is not a hack of the site; it is the gateway getting in the way, and the browser is right to stop.
- Signing in does not make the network private; it only unlocks internet access.
- The phone did not lose the login by magic; a new private MAC address or a new IP can look like a new device to the gateway.
Try it yourself
Run these on your own computer to see Captive portal at work.
Trigger the portal by hand
Open any plain http:// address in the browser, such as http://example.comPlain HTTP can be redirected to the login page; HTTPS cannot.
See the redirect (any OS)
curl -v http://example.com/Behind a portal you get a 302 with a Location header instead of the real page.
Wi-Fi state (Linux)
nmcli networking connectivity checkAnswers portal when NetworkManager detects a captive portal, full when online.
Wi-Fi state (Windows)
netsh wlan show interfacesShows you are connected to the Wi-Fi even while the portal still blocks the internet.
Captive portal at a glance
- Layer
- Application (7), enforced at 3 and 4
- Ports
- 80 for the redirect, 443 for the login page
- Detection
- OS test request over plain HTTP
- Redirect
- HTTP 302 Found, or DNS tricks
- Modern discovery
- DHCPv4 option 114, DHCPv6 option 103, RA option 37
- API media type
- application/captive+json
- Tracks you by
- MAC and IP address
- Defined in
- RFC 8910 and RFC 8908, overview in RFC 8952
Defined inRFC 8910RFC 8908RFC 8952RFC 6585
Header fields
What Captive portal puts in its messages, with example values from the stories above.
DHCP
- Your IP
10.10.3.57- Router
10.10.0.1- DNS server
10.10.0.1The gateway answers DNS itself, so name lookups work even before login.- Option 114 (Captive-Portal)
https://portal.example.com/api/captiveRFC 8910 lets the network tell the phone up front: there is a portal, ask this address.
DNS
- Question
check.example.net, type A- Answer
check.example.net A 198.51.100.80
HTTP/1.1
- Path
/generate_204This test page always answers with an empty 204 on a working internet. Anything else means something is in the way.- Status
302 FoundA redirect. Since the phone expected 204, it now knows it is behind a captive portal.- Location
https://portal.example.com/login?ap=lobby-2&url=...Where to sign in. The phone opens this in a small sign-in window.
Test yourself
How does a phone notice a captive portal?
Questions people ask
Why is the hotel Wi-Fi login page not showing up?
Your phone may not have run its test, or you opened an https:// site first. Open a plain http:// address such as http://example.com, or turn Wi-Fi off and on to trigger the sign-in prompt.
Is hotel or airport Wi-Fi safe to use?
The Wi-Fi is usually open, so traffic on the air is not encrypted by the network. Sites using HTTPS are still protected. For extra safety use a VPN after signing in.
Why does public Wi-Fi say connected, no internet?
You joined the Wi-Fi but have not signed in to the portal yet, or your session expired. Look for the sign-in notice or open a plain http:// page.
Why do I have to log in to public Wi-Fi again and again?
Sessions expire, and many phones use a private MAC address that can change. The gateway then sees a new device and asks again.
What is the captive portal API?
A standard from RFC 8908. The network gives the device a URL in DHCP, and the device fetches JSON that says if it is captive, where to sign in and how long the session lasts.