Why Is My Website Slow? Measure DNS, TLS and Server Time with curl

Networking 8 min readUpdated Nov 17, 2026
3 views0 comments
Streaks of orange car lights along a city street at sunset, suggesting speed
Photo: Rula Sibai rulasibai / Wikimedia Commons (CC0, public domain). source

“My website is slow” can mean five different things: the name lookup, the network connection, the secure handshake, the server thinking, or a heavy page to download. Each has a different fix, and guessing wastes days. The free curl command splits a request into those stages and gives every one a number, so you can see where the time goes in about ten seconds. This guide shows how to read the numbers, with real output, and what to do about each result.

The five stages of a web request

  1. DNS lookup: your computer asks DNS for the server’s IP address.
  2. TCP connect: it opens a connection to that address. This takes about one round trip, so it depends on distance.
  3. TLS handshake: for https, both sides agree on encryption. It takes one or two more round trips.
  4. Waiting for the server: the server receives the request, runs your code and database queries, and starts replying. The moment the first byte arrives is the time to first byte (TTFB).
  5. Download: the rest of the page arrives. This depends on the page size and your connection speed.

The curl variables, and one trap

curl can print these timings with its -w (write-out) option:

Variable Measured until
%{time_namelookup} the DNS lookup is done
%{time_connect} the TCP connection is open
%{time_appconnect} the TLS handshake is done (https only)
%{time_starttransfer} the first byte arrived (TTFB)
%{time_total} the whole transfer finished

The trap: every one of these is counted from the very start of the request. They are cumulative, not separate. To get the time of one stage, subtract the one before it:

Stage Calculation
DNS time_namelookup
TCP connect time_connect − time_namelookup
TLS handshake time_appconnect − time_connect
Server wait time_starttransfer − time_appconnect
Download time_total − time_starttransfer

Your first measurement

curl -s -o /dev/null -w 'dns=%{time_namelookup} connect=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer} total=%{time_total} size=%{size_download} http=%{http_code} ver=%{http_version}\n' https://example.com/
  • -s hides the progress bar and -o /dev/null throws the page away, so only the timing prints.
  • Always include the \n at the end, or the next prompt appears on the same line.

Run from a server with a fast connection, three runs looked like this:

dns=0.010044 connect=0.012963 tls=0.023823 ttfb=0.033703 total=0.034209 size=577 http=200 ver=2
dns=0.008763 connect=0.011352 tls=0.025489 ttfb=0.038296 total=0.039295 size=577 http=200 ver=2
dns=0.008939 connect=0.011981 tls=0.023124 ttfb=0.036689 total=0.038151 size=577 http=200 ver=2

That is a fast request: 38 milliseconds in total, and every stage tiny. The ver=2 shows the connection used HTTP/2.

A friendlier layout with a format file

For a readable report, save the format in a file. Each line needs an explicit \n, because curl ignores the line breaks of the file itself:

cat > curl-format.txt <<'EOF'
    DNS lookup: %{time_namelookup}s\n
   TCP connect: %{time_connect}s\n
 TLS handshake: %{time_appconnect}s\n
Start transfer: %{time_starttransfer}s\n
         Total: %{time_total}s\n
EOF
curl -s -o /dev/null -w "@curl-format.txt" https://your-site.example/
    DNS lookup: 0.008967s
   TCP connect: 0.758909s
 TLS handshake: 1.779143s
Start transfer: 3.235559s
         Total: 11.213381s

This run was made from a slow home connection to a WordPress site. Minutes earlier the same site had answered in about 2.4 seconds from the same PC, and from a server it would take a fraction of that. Numbers swing a lot with the connection, which brings up the first rule of testing: where and when you measure matters, so never trust a single run.

On Windows

Windows 10 and 11 include curl, but in Windows PowerShell 5.1 the word curl is an alias for a different command, Invoke-WebRequest, and the options do not work. Type curl.exe to get the real program, and use NUL instead of /dev/null:

curl.exe -s -o NUL -w 'dns=%{time_namelookup} connect=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer} total=%{time_total} size=%{size_download}\n' https://example.com/

A worked example: where did the time go?

Here is a real run against a WordPress site (its home page, about 185 KB), from a home PC:

dns=0.027672 connect=0.203876 tls=0.404280 ttfb=0.828925 total=2.385944 size=185514

Subtract each number from the one before it:

Stage Calculation Time
DNS 0.028 0.03 s
TCP connect 0.204 − 0.028 0.18 s
TLS handshake 0.404 − 0.204 0.20 s
Server wait (TTFB part) 0.829 − 0.404 0.43 s
Download 2.386 − 0.829 1.56 s

The biggest slice by far is the download: 185 KB took 1.56 seconds, a speed of about 120 KB/s. The server answered in under half a second. So the site was not slow, the test connection was. That is the kind of conclusion you cannot reach by guessing, and it is why you should run the test more than once and from more than one place.

How to read your results

If this is large… It points to… What to do
DNS (over about 0.1 s on repeat runs) A slow or distant DNS provider, or a very low DNS cache time Use a faster DNS host, and check the record TTLs. The first lookup is always slower; repeat it. See our DNS troubleshooting guide.
TCP connect (much more than the ping time) Distance or network loss between you and the server Put a CDN in front of the site, or host closer to your visitors.
TLS handshake (several hundred ms) An old TLS setup, or a far server Enable TLS 1.3 and HTTP/2, and keep the certificate chain short. Free HTTPS with Let’s Encrypt sets this up.
Server wait (the time between TLS and TTFB) The server is slow to produce the page: PHP, database queries, no caching Turn on page caching, use a current PHP version, find slow database queries, and check the server’s CPU and memory.
Download (total − TTFB) A heavy page or a slow connection Enable compression, shrink images, remove unused scripts. Test from a faster connection to separate the two.

A common guideline from Google’s web performance team is to keep the time to first byte under about 0.8 seconds for most visitors. Anything much higher is worth investigating, starting with the server-wait stage.

Make the test reliable

  • Run it several times. The first request may be slower (cold cache, DNS lookup). Compare three to five runs and use the typical one, not the best or the worst.
  • Measure from two places. Run curl on your own PC and on the server (or another server). If the server shows 40 ms and your PC shows seconds, the problem is the network path, not the website. If both are slow, the site itself is slow.
  • Set time limits so a dead site does not hang the command: --connect-timeout 5 --max-time 10.
  • Test a heavy page as well as the home page. The home page is often cached while an article or a search page is not.

More checks with the same tool

Redirects

Every redirect costs a whole new request. Follow them and count:

curl -s -o /dev/null -L -w 'redirects=%{num_redirects} final=%{url_effective} total=%{time_total}\n' http://example.com/

If a visitor typing http:// or www is bounced through two or three redirects before the real page, fix the redirect chain so there is one hop at most.

Is the page compressed?

curl -sI -H 'Accept-Encoding: gzip, br' https://example.com/ | grep -i content-encoding
content-encoding: br

br (Brotli) or gzip means the server compresses the page. If the line is missing for an HTML page, turning compression on is one of the cheapest speed-ups available.

Which HTTP version?

%{http_version} prints 1.1, 2 or 3. HTTP/2 lets the browser load many files over one connection and is usually faster for pages with many images and scripts.

Test a new server before you switch DNS

While moving hosting you can ask curl to use a specific IP address for a name, without changing any DNS record:

curl -s -o /dev/null --resolve example.com:443:203.0.113.10 -w 'http=%{http_code} ver=%{http_version} total=%{time_total}\n' https://example.com/

Replace 203.0.113.10 with the new server’s address. It is a safe way to check that the new site answers, and how fast, before visitors are sent there. See how to switch hosting providers safely.

Use the browser as a second opinion

In Chrome, Edge or Firefox press F12, open the Network tab, reload the page, and click the first request. The Timing section shows the same stages. Waiting for server response is the time to first byte. The waterfall chart then shows every other file, so you can spot the one huge image or the slow third-party script that curl cannot see, because curl only fetches the HTML.

For a quick check without the command line, you can use our free Page Speed Checker, and the Website Uptime Checker to confirm that a site is reachable at all.

Quick reference

# One-line timing report
curl -s -o /dev/null -w 'dns=%{time_namelookup} connect=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer} total=%{time_total}\n' https://example.com/

# Stage times = difference between neighbours:
#  DNS = namelookup | TCP = connect-namelookup | TLS = appconnect-connect
#  Server wait = starttransfer-appconnect | Download = total-starttransfer

curl -sI -H 'Accept-Encoding: gzip, br' URL | grep -i content-encoding   # compression
curl -s -o /dev/null -L -w '%{num_redirects}\n' URL                      # redirect count
curl --resolve host:443:IP https://host/                                 # test a specific server

# Windows PowerShell: use curl.exe and NUL
curl.exe -s -o NUL -w '...' URL
Did you find this helpful?Tap the heart to let us know. It takes one second and no account.

More tutorials like this

Leave a Comment

Your email address will not be published. Required fields are marked *

Bigland Network IT

Practical tutorials for people who run, build and fix things: operating systems, databases, development, networking and security.

Topics

More

Site

© 2026 Bigland Network. All rights reserved.Always test commands on a non-production system first.
Scroll to Top