511 Network Authentication Required
The client needs to authenticate to gain network access.
Usually happens because:
- ☑ Unauthenticated connections to public airport
- ☑ Captive portal page redirections.
🔍 Quick Checklist:
Meaning
The HTTP 511 Network Authentication Required server error status code indicates that the client needs to authenticate to gain network access. It is primarily returned by intercepting proxies (e.g. Wi-Fi captive portals).
Root Causes
- Unauthenticated connections to public airport or hotel Wi-Fi networks.
- Captive portal page redirections.
| Cause | Frequency |
|---|---|
| Unauthenticated connections to public airport | ⭐⭐⭐⭐⭐ |
| Captive portal page redirections. | ⭐⭐⭐⭐ |
Common Mistakes
- Using 401 Unauthorized instead of 511 (use 401 for logging in to a specific website; use 511 for logging in to the physical network provider like Wi-Fi).
How to Fix
Framework-Specific Examples
Express router returning 511 for unauthenticated gateways.
app.get('/gateway', (req, res) => {
res.status(511).set('Location', 'https://wifi-portal.com').send('Network auth required');
});Server Configuration Examples
Nginx proxy rules for captive portal intercepts.
# Captive portal redirects returning 511Prevention
- Ensure web sockets or long polling handles captive portal transitions gracefully.
Frequently Asked Questions (FAQ)
Q: What is a captive portal?
A captive portal is a web page displayed to newly connected users of a public Wi-Fi network (like airports or hotels) before they are granted broader internet access.
Q: Why did HTTP introduce the 511 status code?
To prevent security issues where captive portals hijacked origin website links, which confused browsers and triggered HTTPS certificate errors.
Q: How do modern OSes handle 511 responses?
Operating systems periodically fetch specific URLs (like Apple's captive portal check). If they receive 511 or a redirect, they immediately display a login popup window.
Q: Is 511 cacheable?
No. The 511 Network Authentication Required status code is never cached.