curl Explained for Beginners: Read What a Web Server Tells You
A web browser hides almost everything that happens when it loads a page. curl does the same job from the command line, and if you ask, it shows you every step. Here's how to read what it tells you.
A small home network to try curl on: a PC, a switch, the homelab's DNS server and a web server with a home page, a page that moved (/old to /new) and nothing else (404). Open a shell on the PC and make requests.
The lab
The same small home network as the dig episode: a PC, the homelab's DNS server, and a web server at 10.0.10.80. The web server has a home page, and one page that has moved somewhere else.
Fetching a page
curl http://web.homelab.test
<!doctype html> <title>web.homelab.test</title> <h1>It works</h1>
What this shows
In its simplest form, curl asks for a page and prints whatever the server sent back. For a web page, that's the page's HTML: the heading, It works.
curl -I http://web.homelab.test
HTTP/1.1 200 OK Server: homelab-web/1.0 Date: Mon, 26 Oct 2026 21:06:12 GMT Content-Type: text/html; charset=utf-8 Content-Length: 66
What this shows
Add dash capital I, and curl asks for just the headers. The first line is the status: 200 OK, the server found the page. Then facts about it: it's HTML, and it's 66 bytes long. When something's wrong, the status line is the first thing to read.
The whole conversation
curl -v http://web.homelab.test
* Host web.homelab.test:80 was resolved. * IPv6: (none) * IPv4: 10.0.10.80 * Trying 10.0.10.80:80... * Established connection to web.homelab.test (10.0.10.80 port 80) from 10.0.10.20 port 57870 * using HTTP/1.x > GET / HTTP/1.1 > Host: web.homelab.test > User-Agent: curl/8.21.0 > Accept: */* > * Request completely sent off < HTTP/1.1 200 OK < Server: homelab-web/1.0 < Date: Mon, 26 Oct 2026 21:06:17 GMT < Content-Type: text/html; charset=utf-8 < Content-Length: 66 < <!doctype html> <title>web.homelab.test</title> <h1>It works</h1> * Connection #0 to host web.homelab.test:80 left intact
What this shows
Dash v shows the whole conversation, and every line starts with one of three symbols. A star is curl telling you what it's doing. First, it looked up the name, and got the address 10.0.10.80. Then it connected to that address, on port 80. Lines starting with a greater-than sign are what curl sent: get the page called slash, from the host web dot homelab dot test. Lines starting with a less-than sign are what came back: 200 OK, and the headers. And then the page itself. Name, connection, request, response: four steps, and dash v shows each one.
Status codes
curl -I http://web.homelab.test/missing
HTTP/1.1 404 Not Found Server: homelab-web/1.0 Date: Mon, 26 Oct 2026 21:06:23 GMT Content-Type: text/html; charset=utf-8 Content-Length: 68
What this shows
Now ask for a page that doesn't exist. 404, not found. The server is fine; it just has no page by that name.
curl -I http://web.homelab.test/old
HTTP/1.1 301 Moved Permanently Server: homelab-web/1.0 Date: Mon, 26 Oct 2026 21:06:25 GMT Content-Type: text/html; charset=utf-8 Content-Length: 0 Location: /new
What this shows
This one has moved. 301, moved permanently, and the Location header says where it went: slash new.
curl -L http://web.homelab.test/old
<!doctype html> <title>new page</title> <h1>You followed the redirect</h1>
What this shows
Browsers follow that kind of move without asking. curl doesn't, unless you add dash capital L. Then it follows the redirect, and fetches the new page.
Where did it stop?
curl http://nope.homelab.test
curl: (6) Could not resolve host: nope.homelab.test (Domain name not found)
What this shows
When curl can't get a page at all, its error number tells you which step failed. Here: error 6, could not resolve host. It never got an address for the name, so it never even tried to connect. That's a DNS problem, and dig, from the last explainer, is the tool to look closer.
curl http://10.0.10.53
curl: (7) Failed to connect to 10.0.10.53:80 after 0 ms: Could not connect to server
What this shows
And here: error 7, failed to connect. There is an address, the DNS server's, but nothing on it is serving web pages on port 80, so the connection is turned away.
Recap
So when a website won't load, run curl. Error 6: the name didn't resolve, so look at DNS. Error 7: nothing answered at that address and port. And if you got a status code, the server did answer: read the number.
On Windows and Mac
Not on Linux? On a Mac, curl is built in: open Terminal and type the same commands. Windows 10 and 11 include it too. In PowerShell, type curl dot exe, because plain curl can run a different PowerShell command, Invoke-WebRequest, instead. The Learn page on networkincidents.ca has the details.
| Mac | curl -v http://web.homelab.test | in Terminal: built in, the same command |
| Windows | curl.exe -v http://web.homelab.test | built into Windows 10 and 11 |
| PowerShell | curl.exe, not curl | plain curl can run Invoke-WebRequest instead |
When a page won't load, curl dash v shows which step it stopped at: the name, the connection, the request, or the response.
Try it yourself
The whole lab runs on your own computer with Docker and containerlab: get it on GitHub, then ./lab.sh up and ./lab.sh break. Setup steps are on Run the labs.