The user list on your page takes more than a second to appear. Is the server slow, or your internet? Or did the request fail without any message? The Network panel in DevTools answers questions like these.
Network records every request a page makes: its HTML file, CSS, JavaScript, images, and even API calls through fetch. Each request is one row, with its status, type, size and duration. You can click a row to see what's inside. Network is like the order history in a food delivery app. One order is one request. Tap one order and you see three things: what you ordered (what the browser sent), what came (the server's answer), and where the time went. The time can go in the restaurant's kitchen (the server working) or on the road (the network).
Recording requests
Network only records while DevTools is open. So open the Network panel first, then do the action you want to check. To see everything the page loads from the start, press Ctrl+R (Mac: Cmd+R) while Network is open. The page reloads, and all its requests are recorded. The Network toolbar has two checkboxes you'll use a lot:
- Preserve log: the record isn't wiped when the page navigates.
- Disable cache: every file is fetched again from the server, not from the cache (the copies the browser keeps). This checkbox only works while DevTools is open.
Reading the request table
The user list page at http://localhost:3000 makes five requests:
| Name | Status | Type | Size | Time |
|---|---|---|---|---|
index.html |
200 | document | 5.2 kB | 98 ms |
logo.png |
200 | png | 15.3 kB | 40 ms |
missing.png |
404 | png | 300 B | 22 ms |
users |
200 | fetch | 620 B | 125 ms |
auth |
401 | fetch | 310 B | 43 ms |
- Name is the end of the URL. Type is its kind (
fetchmeans JavaScript called that request). Size is what travelled over the network, and Time is how long it took from start to finish. - Failed requests are written in red. Here that's
missing.png(404) andauth(401). The Console records them too, for exampleGET http://localhost:3000/api/auth 401 (Unauthorized). - The filter buttons above the table (All, Fetch/XHR, Doc, CSS, JS, Img...) filter the rows by kind. For API work, pick Fetch/XHR. XHR is the older way to call an API, from before
fetchexisted.
Status codes: the server's answer in three digits
2xxsuccess:200 OK,201 Created(new data was made),204 No Content.3xxa redirect or the cache:301and302point to another URL.304 Not Modifiedmeans "the file hasn't changed since you got it, use the copy in your cache". When the browser asks for the file again, it sends a version tag of the copy it kept. If the version is still the same, the server answers 304 with no body (no contents), so the size is tiny.4xxsomething wrong with the request:400the data sent isn't valid,401not logged in or no token (a code that shows you are logged in),403logged in but not allowed,404not found,422validation failed (Laravel, a PHP framework, uses this for forms).5xxsomething wrong on the server:500 Internal Server Error,503the server can't serve right now.- No number at all. When a request fails before there is an answer the page may read, the Status column shows text, not a number:
(failed)is followed by the error message, for example when the server is down or the internet connection drops.CORS errormeans the browser refused an answer from another domain, because that server does not allow your page to read it.(blocked:origin)means the headers are set up wrong. Headers are extra information sent along with a request or an answer. Hover over that text to see a hint.
In code, a fetch that fails because the server is down and a fetch that fails because of CORS both throw the same TypeError: Failed to fetch. So the Network panel is what tells you the cause.
The details of one request
Click a row and its detail pane opens with several tabs:
- Headers: the URL, the method (
GET,POST...), the status code, then the Response Headers from the server and the Request Headers the browser sent. - Payload: the data sent, such as a form's contents or a JSON body.
- Preview: the answer tidied up. JSON shows as a tree you can open.
- Response: the raw answer, exactly the text the server sent.
- Timing: that request's time breakdown.
Why is auth 401? Open its Headers tab: there's no Authorization: Bearer ... in the Request Headers. This means the code forgot to send the token. The Response tab shows the server's answer: {"message":"Unauthenticated."}. Once the header is added, the status becomes 200.
Timing: where the time goes
The Timing tab splits one request's time into several phases:
| Phase | What it is | If it's long, suspect |
|---|---|---|
| Queueing, Stalled | waiting for a turn in the browser | too many requests at once |
| DNS Lookup | finding the IP for the domain name | slow DNS |
| Initial connection | opening the connection (SSL included for https) | a far-away server |
| Request sent | sending the request | a big upload |
| Waiting for server response | waiting for the first byte of the answer (TTFB) | the server: a slow database query, a cold start (a server that has just started), heavy processing |
| Content Download | downloading the answer | a big answer or a slow connection |
A normal users request: Waiting is 120 ms out of 125 ms in total. If Waiting becomes 1,200 ms while the other phases stay fast, the server needs a long time to think. The problem is the server, not your connection. Faster internet won't help. What has to be fixed is the backend code (the code that runs on the server) or its query. In the opposite case, if Content Download is the long one, make the answer smaller, for example with compression or pagination (splitting the data into pages).
Other tools in the toolbar
- Throttling (the menu that starts as No throttling) makes the connection slower on purpose. Pick a slow setting such as Slow 4G, or Offline, to see your loading state and error handling.
- Right-click a request, then Copy, Copy as cURL: copies the same request as a terminal command.
- Right-click a request, then Block request URL: that file acts as if it failed to load, to test your fallback (the backup plan when a file fails to load).
⚠️ Misreading the Network panel
- Opening Network after the request is already over. The table is empty. Open it first, then repeat the action that made the request, or press
Ctrl+R. - Thinking 304 is an error. 304 means your cache is still right. Failure starts at 400.
- Only looking at the status. A 200 but an empty list on screen? Open Preview or Response: maybe the data is empty, or shaped differently from what you expected.
- Measuring speed with Disable cache on. Returning visitors use the cache, so measure without that box ticked too.
TL;DR: The Network panel in DevTools records every request a page makes while DevTools is open. So open it first, then repeat the action you want to check, or press Ctrl+R to reload the page. Each row has a Name, Status, Type, Size and Time. Failed requests are red, and the Fetch/XHR filter leaves only the API calls. Status codes (the server's number for its answer): 2xx success, 3xx a redirect or the cache (304 Not Modified: use the cached copy, the answer has no body), 4xx something wrong with the request (401: no login token), 5xx something wrong on the server. Click a request to see the Headers tab (the extra information sent and received), Payload (the data sent), Preview and Response (the answer's body), and Timing (the time per phase). If the Waiting for server response phase (TTFB: the time until the first byte of the answer arrives) is long while the other phases are fast, the server is slow.
⚡ Open Network first, then act
Meaning: The Network panel in DevTools records every request a page makes, but only while DevTools is open. Open the panel first, then repeat the action you want to check, or press Ctrl+R to reload the page. For API calls, pick the Fetch/XHR filter.
⚡ The server's answer in three digits
Guess first: each request has a status code, a three-digit number from the server. Is 304 Not Modified an error?
No. It means the file hasn't changed, so the browser uses the copy in its cache (the copies it keeps). Failure starts at 400.
Meaning: 2xx success, 3xx a redirect or the cache, 4xx something wrong with the request (401: no login token), 5xx something wrong on the server.
⚡ Click the request
Meaning: In the Network panel, click a request's row to see its details. The Headers tab holds the extra information the browser sent and the server sent back. Preview and Response hold the answer's body. For example, a request to auth got a 401 (not logged in). Its Request Headers have no Authorization: Bearer ...: the code forgot to send the login token.
⚡ A long Waiting means the server
Guess first: the Timing tab splits one request's time into phases. The Waiting for server response phase (waiting for the server's answer) is 1,200 ms, the other phases are fast. Is your internet slow?
No. The server needs a long time to think, a slow database query for example. Faster internet won't help.
Meaning: Look at which phase is long in the Timing tab, and you know what to fix.