Error 401 Unauthorized berarti server belum menerima kredensial autentikasi yang valid. Penyebabnya dapat berupa header yang hilang, token kedaluwarsa, API key salah, cookie session bermasalah, atau respons yang dibuat oleh proxy dan gateway. Diagnosis paling cepat dimulai dari WWW-Authenticate, kemudian berlanjut ke token, format header, izin, dan log.
Error 401 Unauthorized berarti server belum menerima kredensial autentikasi yang valid. Penyebabnya bukan selalu server sedang bermasalah: request mungkin tidak mengirim kredensial, token sudah kedaluwarsa, API key salah, cookie sesi rusak, atau respons 401 justru dibuat oleh proxy, gateway, CDN, atau layanan challenge sebelum mencapai aplikasi utama.
As an Amazon Associate I earn from qualifying purchases.
Untuk menemukan penyebabnya, mulai dari header WWW-Authenticate, kemudian periksa kredensial yang dikirim, format header, masa berlaku token, cookie atau sesi, scope, dan log pada setiap lapisan jaringan.
Apa arti 401 Unauthorized?
HTTP 401 Unauthorized adalah status respons ketika server menerima request, tetapi tidak dapat menganggap client sudah terautentikasi. Istilah “Unauthorized” agak menyesatkan karena makna praktisnya lebih dekat dengan unauthenticated: identitas client belum diberikan atau kredensialnya tidak valid.
#1 Best Overall
- Reliable Plug and Play: The USB receiver provides a reliable wireless connection up to 33 ft (1), so you can forget about drop-outs and delays and you can take it wherever you use your computer
- Type in Comfort: The design of this keyboard creates a comfortable typing experience thanks to the low-profile, quiet keys and standard layout with full-size F-keys, number pad, and arrow keys
- Durable and Resilient: This full-size wireless keyboard features a spill-resistant design (2), durable keys and sturdy tilt legs with adjustable height
- Long Battery Life: MK270 combo features a 36-month keyboard and 12-month mouse battery life (3), along with on/off switches allowing you to go months without the hassle of changing batteries
- Easy to Use: This wireless keyboard and mouse combo features 8 multimedia hotkeys for instant access to the Internet, email, play/pause, and volume so you can easily check out your favorite sites
Menurut referensi HTTP MDN, respons 401 biasanya menyertakan header WWW-Authenticate. Header ini memberi tahu client skema autentikasi yang dapat digunakan.
GET /api/profile HTTP/1.1
Host: example.com
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer
Setelah mengetahui challenge tersebut, client dapat mencoba kembali dengan kredensial yang sesuai. Contoh berikut memakai skema Bearer:
GET /api/profile HTTP/1.1
Host: example.com
Authorization: Bearer TOKEN_AKSES
Bearer bukan satu-satunya metode autentikasi. Layanan berbeda dapat menggunakan API key, Basic Auth, cookie session, OAuth, mutual TLS (mTLS), atau skema lain. Ikuti dokumentasi layanan dan jangan menebak nama header atau format token.
Penyebab umum error 401
1. Kredensial tidak dikirim
Endpoint yang dilindungi akan menolak request jika header autentikasi, cookie session, atau kredensial lain yang diwajibkan tidak ikut terkirim. Hal ini sering terjadi ketika kode aplikasi hanya menambahkan token pada sebagian request, konfigurasi client HTTP belum dimuat, atau proxy menghapus header sebelum request sampai ke server.
Periksa request aktual yang keluar dari aplikasi, bukan hanya kode sumbernya. Pastikan endpoint, metode HTTP, dan header autentikasinya benar.
Rank #2
- Dependable wireless connection: Enjoy the reliability and convenience of 2.4 GHz connectivity with your logitech wireless keyboard and mouse combo, wireless range up to 10 meters away at home, or work.
- Full-Size Wireless Keyboard: Comfortable, quiet typing on a familiar keyboard layout with palm rest, spill-resistant design, and media keys. This wireless keyboard and mouse logitech has easy-access to media keys
- Plug and Play: MK345 works seamlessly with Windows, macOS, and ChromeOS. Experience hassle-free setup with the logitech mk345 wireless combo and wireless keyboard mouse combo for various operating systems.
- Long-lasting Battery: The MK345 combo offers a full size keyboard battery life of up to 3 years and a mouse battery life of 18 months (1); batteries included
- Comfortable Right-handed Mouse: This wireless USB mouse with dongle works well for this wireless mouse and keyboard combo, featuring a contoured shape for all-day comfort and smooth, precise tracking and scrolling for easier navigation.
2. Token atau API key salah, kedaluwarsa, atau sudah dicabut
Token dapat ditolak karena sudah melewati masa berlaku, salah salin, terpotong oleh konfigurasi deployment, dicabut, atau dibuat untuk environment yang berbeda. API key staging, misalnya, belum tentu valid pada endpoint production.
Dokumentasi Cloudflare tentang error 401 juga menyarankan pemeriksaan kredensial, format, serta status aktif token atau key.
3. Format header autentikasi keliru
Kesalahan kecil dapat membuat kredensial dianggap tidak ada atau tidak valid, termasuk:
- menggunakan nama header yang salah;
- lupa menulis prefix skema, misalnya
Bearer; - memakai spasi atau encoding yang tidak sesuai;
- mengirim API key di header yang berbeda dari ketentuan provider;
- mengirim token sebagai body atau query parameter padahal layanan mengharuskan header
Authorization; - menggunakan token dengan tanda kutip tambahan atau karakter tersembunyi.
Gunakan WWW-Authenticate dan dokumentasi provider sebagai petunjuk awal. Jangan mengganti skema autentikasi secara acak.
4. Scope, audience, role, atau izin token tidak cocok
Autentikasi dan otorisasi adalah dua tahap berbeda. Autentikasi menjawab “siapa client ini?”, sedangkan otorisasi menjawab “apa yang boleh dilakukan client tersebut?”.
Rank #3
- Durable and Reliable: This USB keyboard features a curved space bar, spill-resistant design (2), durable keys that can withstand 10 million keystrokes, and sturdy, adjustable tilt legs
- Comfortable, Familiar Typing: You’ll enjoy a comfortable and familiar typing experience thanks to the deep-profile keys and standard layout with full-size F-keys and number pad
- Full-size Sculpted Mouse: The high-definition optical USB mouse puts comfort and control in your hands with smooth, accurate tracking and an ambidextrous shape that feels good hour after hour
- Simple Set-Up: Simply plug the keyboard and mouse into the USB ports on your desktop, laptop, or netbook and you're ready to work; compatible with Windows 7, 8, 10 or later
- Clear and Convenient: The bold, bright white and long-lasting characters make the keys on this PC or laptop keyboard easy to read and extra durable
Token yang valid tetap dapat gagal digunakan pada endpoint tertentu apabila scope, audience, role, atau issuer-nya tidak sesuai. Sebagian layanan mengembalikan 401 untuk kondisi ini, sementara layanan lain memakai 403. Perilakunya bergantung pada implementasi.
Recommended Free Tools
5. Cookie atau session browser bermasalah
Pada website berbasis login, browser dapat kembali dianggap belum login karena session kedaluwarsa, cookie terhapus atau diblokir, perubahan domain, masalah SameSite, atau extension yang memodifikasi request.
Cobalah:
- login ulang pada website;
- membuka halaman dalam jendela private atau incognito;
- menguji browser lain;
- menonaktifkan sementara extension yang memblokir atau mengubah request;
- memastikan cookie untuk layanan tersebut tidak diblokir.
Jika masalah berkaitan dengan challenge Cloudflare, dokumentasi troubleshooting Cloudflare menyarankan browser yang mutakhir, JavaScript aktif, serta pengujian tanpa VPN atau proxy.
6. 401 dibuat proxy, gateway, CDN, atau challenge
Dalam sistem berlapis, server aplikasi bukan satu-satunya komponen yang dapat mengirim 401. Respons tersebut bisa berasal dari:
- reverse proxy;
- API gateway;
- identity provider;
- CDN atau firewall aplikasi;
- origin server;
- layanan challenge pada browser.
Karena itu, periksa header respons, nama server, request ID atau Ray ID, dan log pada setiap lapisan. 401 yang terlihat oleh browser belum tentu berasal dari kode aplikasi.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchRank #4
- 【Ergonomic Wireless Keyboard Mouse 】: Wireless ergonomic keyboard is equipped with adjustable height tilt legs to increase comfort and prevent your wrists injury when typing for a long time. The full size wireless keyboard with numeric keypad and 12 multimedia shortcut keys, such as play/ pause, volume increase and decrease, and email, to help you improve work efficiency
- 【Stable & Reliable Wireless Connection】: This wireless keyboard and mouse combo share the same USB receiver(stored in the mouse), and they can also be used separately. Plug & play, no need to download any software, 2.4 GHz wireless provides a powerful and reliable connection up to 33 feet(10m) without any delays.You can enjoy the convenience and freedom of wireless connection at home or at work
- 【Comfortable Optical Mouse】: This compact lightweight wireless mouse features a hand-friendly contoured shape for all-day comfort, and smooth, precise tracking.1600 DPI to meet your daily needs. Perfect for home & office work and entertainment
- 【Long Battery Life】: Up to 365 Days of battery life for keyboard and mouse wireless, say goodbye to the hassle of charging cables and replacing batteries. After 10 minutes of inactivity, the wireless keyboard mouse combo will automatically go into sleep mode to save energy. The wireless keyboard requires one AAA battery, and the wireless mouse requires one AA battery.
- 【Less Noise, More Quiet Keys】: Soft membrane keys provide a quiet and comfortable typing experience, So you can type with confidence on a wireless keyboard crafted for comfort, precision and fluidity. The wireless mouse adopts silent micro-motion technology, which is almost completely silent when clicked. No more concerns about disturbing others.
Cloudflare juga menjelaskan kasus khusus ketika request Private Access Token pada challenge tertentu menghasilkan 401 secara normal karena perangkat atau jaringan tidak dapat menerbitkan token. Respons ini tidak dengan sendirinya membuktikan bahwa visitor diblokir atau widget challenge rusak.
Cara mengatasi 401 dari sisi pengguna
- Baca detail respons. Cari
WWW-Authenticate, pesan error, request ID, atau Ray ID jika tersedia. - Login ulang jika error muncul pada website biasa.
- Uji private/incognito window untuk memisahkan masalah cookie, session, dan extension.
- Periksa cookie dan JavaScript. Sebagian layanan memerlukannya untuk login atau challenge.
- Perbarui browser dan coba browser atau perangkat lain.
- Matikan VPN atau proxy sementara untuk mengisolasi masalah jaringan. Aktifkan kembali setelah pengujian jika memang dibutuhkan.
- Jika memakai API, periksa endpoint, environment, token, API key, dan header
Authorization. - Hubungi pemilik layanan jika kredensial sudah dipastikan benar. Sertakan waktu kejadian, endpoint, status code, dan request ID tanpa mengirim secret.
Contoh pemeriksaan API dengan curl
Untuk melihat header respons tanpa menampilkan token secara sembarangan, gunakan request terkontrol seperti berikut. Ganti nilai placeholder melalui environment variable, bukan dengan menempelkan secret langsung ke riwayat shell:
export API_TOKEN='isi-token-di-lingkungan-aman'
curl -i
-H "Authorization: Bearer ${API_TOKEN}"
https://example.com/api/profile
Perhatikan baris status, WWW-Authenticate, header server, dan request ID. Jika respons tetap 401, pastikan token memang diterbitkan untuk endpoint dan environment tersebut. Setelah selesai, bersihkan variable dari lingkungan kerja sesuai prosedur keamanan Anda.
Cara mengatasi 401 dari sisi developer atau admin
- Pastikan middleware autentikasi aktif pada route yang benar. Periksa apakah route publik tidak ikut terlindungi atau route privat justru melewati middleware.
- Pastikan reverse proxy meneruskan header. Verifikasi bahwa
Authorizationtidak dihapus atau ditimpa sebelum request mencapai origin. - Validasi token. Periksa issuer, audience, signature, expiration, dan toleransi perbedaan waktu atau clock skew.
- Periksa environment variable. Pastikan secret tidak kosong, tidak tertukar antara staging dan production, dan tidak terpotong oleh sistem deployment.
- Cocokkan scope dan role dengan persyaratan endpoint.
- Pastikan API key memakai header dan format provider. Jangan mengasumsikan semua provider menerima
Authorization: Bearer. - Bandingkan konfigurasi gateway, identity provider, dan aplikasi. Ketiganya harus sepakat mengenai issuer, audience, algoritma, key, dan aturan akses.
- Telusuri log secara berurutan dari CDN atau proxy, gateway, identity provider, hingga origin.
- Redaksi secret dalam log. Simpan metadata diagnostik tanpa mencatat token mentah, password, cookie session, atau API key.
- Dokumentasikan challenge autentikasi. Respons
WWW-Authenticateharus mencerminkan skema yang benar-benar didukung layanan.
Checklist diagnosis berlapis
| Lapisan | Yang diperiksa | Petunjuk masalah |
|---|---|---|
| Client | Endpoint, environment, header, cookie, redirect | Token tidak pernah terkirim atau berubah setelah redirect |
| Proxy/CDN | Penerusan Authorization, aturan challenge, header respons |
401 muncul sebelum origin mencatat request |
| Gateway/identity provider | Signature, issuer, audience, expiration, key | Token ditolak saat validasi identitas |
| Aplikasi | Middleware, scope, role, session lookup | Origin menerima request tetapi route mengembalikan 401 |
| Observability | Request ID, waktu, status, alasan penolakan | Log tiap lapisan tidak dapat dikorelasikan |
Untuk sistem yang memiliki banyak endpoint, alat monitoring API dapat membantu mengamati status respons, perubahan header, dan kegagalan request terautentikasi. Namun alat monitoring tidak menggantikan pemeriksaan kredensial; secret tetap harus disimpan dan direkam secara aman.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Perbedaan 401, 403, 407, dan 404
| Status | Makna umum | Langkah utama |
|---|---|---|
| 401 Unauthorized | Autentikasi belum diberikan atau tidak valid. | Kirim atau perbaiki kredensial sesuai challenge. |
| 403 Forbidden | Server mengenali request atau identitas, tetapi akses tidak diizinkan. | Periksa izin, scope, role, atau kebijakan akses. |
| 407 Proxy Authentication Required | Autentikasi diperlukan pada proxy, bukan langsung pada origin. | Periksa kredensial dan konfigurasi proxy. |
| 404 Not Found | Resource tidak ditemukan. | Periksa URL dan route; beberapa server sengaja memakai 404 untuk menyembunyikan resource yang dilindungi. |
Batas antara 401 dan 403 dapat berbeda antar layanan. Jika token valid tetapi scope tidak sesuai, satu API mungkin mengembalikan 403 dan API lain 401.
Best Value
- 【Lag-free & Efficient】Stable and reliable connection of wireless keyboard and mouse is up to 10m(33ft). This combo share a nano USB receiver, no need to take up additional USB ports (Also the wireless keyboard and mouse can also be used separately). Plug and play, no software needed,convenient and efficient.
- 【Quiet & Type in Comfort】Wireless keyboard come with adjustable height tilt legs to increase comfort and prevent your wrists injury when typing for a long time.Our wireless keyboard adopts a silent structure. Soft membrane keys provide a quiet and comfortable typing experience.The wireless mouse is quiet without any clicking sound also.So whether at home or in the office, you can use this combo as you please without worrying about disturbing others.
- 【Full Size Keyboard】This keyboard saves desktop space while retaining its full size.The full size wireless keyboard with numeric keypad and 12 multimedia shortcut keys, such as play/ pause, volume increase and decrease, and search, to help you improve work efficiency.
- 【Auto Power Saving Function】Wireless keyboard and mouse have a smart auto-sleep mode to save power for long battery life. They will enter sleep mode after stop using a while(Refer to the instructions for details). Unplug the receiver or after the PC shutdown, they will enter sleep mode too.You can press any keys to wake. (battery life may vary based on user and computing conditions)
- 【Comfortable Optical Mouse】This silent wireless mice provides 3 adjustable DPI (800/1200/1600) to meet your different needs in terms of sensitivity.The compact lightweight design of wireless mouse and a hand-friendly contoured shape for all-day comfort, and smooth, precise tracking. Very suitable for office and daily use.
Kesalahan keamanan yang harus dihindari
- Jangan menaruh password, token, atau API key di URL. Query string dapat tersimpan pada log server, browser history, analytics, atau sistem perantara. OWASP REST Security Cheat Sheet membahas risiko pengelolaan autentikasi dan secret pada API.
- Jangan mengunggah token ke forum, issue publik, screenshot, atau chat. Jika secret terlanjur bocor, cabut dan rotasi segera.
- Jangan menonaktifkan autentikasi hanya untuk menghilangkan 401. Perbaiki konfigurasi client, server, proxy, atau identity provider.
- Gunakan secret manager atau environment variable yang aman sesuai praktik deployment organisasi.
- Redaksi log. Catat metadata yang membantu diagnosis, bukan nilai credential.
OWASP menempatkan autentikasi pengguna dan session management sebagai bagian penting keamanan REST, termasuk risiko broken user authentication pada API. Karena itu, troubleshooting sebaiknya memperbaiki akar masalah tanpa mengurangi perlindungan endpoint.
Kapan harus menghubungi pemilik layanan?
Hubungi administrator atau penyedia API jika login ulang, pengujian browser atau jaringan lain, dan verifikasi kredensial tidak menyelesaikan masalah. Kirim informasi yang aman untuk dibagikan:
- waktu kejadian dan zona waktu;
- URL atau endpoint tanpa token rahasia;
- metode HTTP;
- status code dan pesan error yang tidak mengandung secret;
- request ID atau Ray ID;
- browser, aplikasi client, atau environment yang digunakan.
Jangan mengirim password, token, API key, cookie session, atau isi header rahasia. Jika dukungan teknis membutuhkan data tambahan, gunakan kanal resmi dan metode redaksi yang disepakati.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsFrequently Asked Questions
Apakah error 401 berarti server sedang down?
Tidak selalu. Error 401 biasanya berarti kredensial belum dikirim, salah, kedaluwarsa, atau ditolak. Server mungkin tetap berjalan normal. Periksa header WWW-Authenticate, token, cookie session, dan lapisan proxy atau gateway.
Bagaimana cara memperbaiki 401 di browser?
Login ulang, coba jendela incognito, periksa cookie dan JavaScript, nonaktifkan sementara extension yang memodifikasi request, lalu uji browser atau jaringan lain. Jika memakai VPN atau proxy, matikan sementara untuk pengujian.
Mengapa API tetap mengembalikan 401 padahal token terlihat benar?
Periksa endpoint, environment, header Authorization, format skema, masa berlaku token, issuer, audience, signature, scope, dan konfigurasi reverse proxy. Telusuri log dari CDN atau gateway hingga origin tanpa mencatat token mentah.
Apa perbedaan error 401 dan 403?
401 menunjukkan autentikasi belum diberikan atau tidak valid. 403 berarti server mengenali request atau identitas, tetapi tidak mengizinkan akses. Namun detail pemakaian keduanya dapat berbeda antar layanan.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
The Bottom Line
Intinya: 401 berarti server belum menerima autentikasi yang valid—bukan otomatis berarti server down. Mulailah dari WWW-Authenticate, lalu periksa header autentikasi, token atau API key, cookie/session, scope, serta proxy atau gateway yang mungkin mengeluarkan respons. Selama debugging, jangan pernah membocorkan credential atau menaruhnya di URL.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




