In one minute
- Three things behind every website:
- DNS turns a name (
api.acme.com) into an IP address. - HTTP is the language of web requests and replies.
- TLS encrypts the connection (the "S" in HTTPS) and proves the server is who it says it is, using a certificate.
- DNS turns a name (
- Most web outages are one of these three: a wrong DNS record, a misread HTTP error, or an expired certificate. "It's always DNS" is a running joke because it is so often true.
- First DNS finds the address. Then a TLS connection is opened and the certificate is checked. Then HTTP sends the request and gets back a status code and a page.
- 👉 "The site is down", "it works for me but not for them", slow pages, and certificate warnings.
Think of it like: making a phone call. DNS = the phone book (name → number). TLS = checking the caller ID and making the line private. HTTP = the actual conversation.
How DNS works
DNS (Domain Name System) is the internet's phone book.
People remember names. Computers need IP addresses.
When an app connects to api.acme.com:
- It checks
/etc/hostsfirst (a small local list of names). - It asks the resolver listed in
/etc/resolv.conf. In AWS, this is the VPC's resolver at the.2address. - The resolver asks the root servers, then the
.comservers, then acme.com's own authoritative name servers (the ones that hold the real answer). - The answer is kept (cached) for its TTL (time to live), in seconds.
cat /etc/hostscat /etc/resolv.confnameserver 10.0.0.2search ec2.internalsearch lets you use short names: ping db1 tries db1.ec2.internal. In Kubernetes pods, /etc/resolv.conf points to CoreDNS (the cluster's DNS), with search domains like default.svc.cluster.local.
Remember it: TTL = how long people may remember the old answer.
Record types
| Type | Maps | Example |
|---|---|---|
| A | Name → IPv4 address | api.acme.com → 203.0.113.10 |
| AAAA | Name → IPv6 address | api.acme.com → 2001:db8::10 |
| CNAME | Name → another name (a nickname) | www → acme.com |
| MX | Where to deliver email | acme.com → mail.acme.com |
| TXT | Free text (domain proofs, email rules) | "v=spf1 include:..." |
| NS | Which servers hold the real answers | acme.com → ns-1.awsdns.com |
| SRV | A service's host and port | Used by Kubernetes, LDAP |
| PTR | IP → name (reverse lookup) | 10 → web1.acme.com |
AWS also has alias records. They can point the bare domain (acme.com) at a load balancer, which a normal CNAME cannot do.
Asking DNS: dig
dig asks a DNS server a question and shows the full answer.
👉 Any time you suspect DNS: "is this name pointing where I think?"
dig example.comdig +short example.com;; ANSWER SECTION:example.com. 300 IN A 93.184.216.34;; Query time: 12 msec;; SERVER: 10.0.0.2#53| Part | Meaning |
|---|---|
300 | TTL: may be cached for 300 seconds |
IN A | An internet A record (name → IPv4) |
SERVER | Which resolver answered |
Useful versions:
dig +short api.acme.com # just the answerdig api.acme.com AAAA # a specific record typedig @8.8.8.8 api.acme.com # ask a specific resolverdig +trace api.acme.com # follow the chain from the rootdig -x 10.0.1.25 # reverse lookupnslookup api.acme.com # older tool, often availablegetent hosts api.acme.com # what the system resolver (incl. /etc/hosts) returnsdig asks DNS directly and ignores /etc/hosts. getent hosts shows what apps really get, including /etc/hosts.
Fixing DNS problems
| What you see | Likely cause | Check |
|---|---|---|
| Works on your laptop, not on the server | Different resolvers, or a private zone | dig @resolver name on both |
| New record not showing yet | The old answer is still cached (TTL) | Compare dig @8.8.8.8 with the local resolver |
NXDOMAIN | The name does not exist | Typo, wrong zone, record never created |
SERVFAIL | The resolver could not get an answer | DNSSEC problems, broken name servers |
| Only one machine is wrong | An old line in /etc/hosts | grep name /etc/hosts |
Before a migration, lower the TTL (for example to 60 seconds) a day ahead. Then when you switch the record, everyone picks up the change quickly.
HTTP from the command line
HTTP is how browsers and apps talk to web servers.
A request has a method (GET, POST...), a path, headers and sometimes a body. The response has a status code, headers and a body.
👉 Testing health checks, APIs and websites.
curl -I https://example.comcurl -v http://localhost/healthHTTP/2 200content-type: text/html; charset=UTF-8cache-control: max-age=604800Status codes you must know
| Code | Meaning | Usual cause in operations |
|---|---|---|
| 200 | OK | |
| 201 / 204 | Created / no content | |
| 301 / 302 | Redirect | HTTP to HTTPS, or a moved path (curl -L follows it) |
| 304 | Not modified | Caching is working |
| 400 | Bad request | The client sent invalid data |
| 401 | Unauthorized | Missing or wrong login details |
| 403 | Forbidden | Logged in, but not allowed; a WAF; an S3 bucket policy |
| 404 | Not found | Wrong path, ingress rule or app route |
| 429 | Too many requests | Rate limiting |
| 500 | Internal server error | A bug or crash in the app: check the app logs |
| 502 | Bad gateway | The proxy reached the app but got a bad answer or none: app crashed or wrong port |
| 503 | Service unavailable | No healthy app behind the proxy, overloaded, or maintenance |
| 504 | Gateway timeout | The app was too slow, so the proxy gave up |
Remember it: 2xx = good. 3xx = go elsewhere. 4xx = you (the client) did something wrong. 5xx = the server broke.
502, 503 and 504 from a load balancer almost always mean the problem is behind it (the app), not in the load balancer itself.
Useful curl recipes
curl -s -o /dev/null -w "%{http_code}\n" https://api.acme.com/healthcurl -w "dns:%{time_namelookup} connect:%{time_connect} tls:%{time_appconnect} total:%{time_total}\n" -o /dev/null -s https://api.acme.comcurl -H "Host: api.acme.com" http://10.0.1.25/ # test a backend directlycurl --resolve api.acme.com:443:10.0.1.25 https://api.acme.com/ # pin DNS for a testcurl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' https://api.acme.com/items- Print only the status code (great for scripts).
- Time each step. This tells you whether slowness is in DNS, the connection, TLS or the app.
- Send a request straight to one server, skipping DNS.
- Pretend DNS points to a certain IP, just for this one test.
- Send JSON data with POST.
TLS and certificates
HTTPS is HTTP inside an encrypted TLS connection. The server proves who it is with a certificate, signed by a trusted certificate authority (CA).
Without it, anyone on the network could read or change the traffic, or pretend to be your site.
Think of it like: a passport. It says who you are (the name), it is issued by a trusted government (the CA), and it has an expiry date.
What a certificate contains:
| Field | Meaning |
|---|---|
| Subject / SAN | Which names it is valid for (api.acme.com, *.acme.com) |
| Issuer | The CA that signed it |
| Not Before / Not After | When it starts and stops being valid |
| Chain | Middle certificates that link it back to a trusted root |
Look at a live certificate:
openssl s_client -connect example.com:443echo | openssl s_client -connect api.acme.com:443 -servername api.acme.com 2>/dev/null | openssl x509 -noout -subject -issuer -dates# subject=CN = api.acme.com# issuer=C = US, O = Let's Encrypt, CN = R11# notBefore=Oct 1 00:00:00 2026 GMT# notAfter=Dec 30 23:59:59 2026 GMTCommon TLS errors
| Error | Meaning | Fix |
|---|---|---|
| certificate has expired | Past its notAfter date | Renew it; automate with cert-manager or ACM |
| hostname mismatch | The name is not in the certificate's list | Get a certificate that covers that name |
| unable to get local issuer certificate | A middle certificate is missing, or a private CA is not trusted | Serve the full chain; add the CA to the trust store |
| self-signed certificate | Not signed by a trusted CA | Use a real CA, or trust the internal CA on purpose |
curl -k skips the certificate check. It is fine for a quick test, but never put it in scripts or real code. It switches off the very protection TLS gives you.
Expired certificates are one of the most common avoidable outages. Automate renewal (Let's Encrypt with cert-manager in Kubernetes, AWS Certificate Manager on load balancers) and set an alert 30 days before expiry.
Real-world scenario: "the site is down" after a DNS change
dig +short example.comdig @8.8.8.8 example.comcurl -I https://example.comdig +shorton the server returns the old load balancer IP.dig @8.8.8.8returns the new one. The TTL was 86400 (one day), so resolvers still remember the old answer.- The old load balancer was already deleted, so anyone with the cached answer fails.
- Fix: bring back the old endpoint for now. Next time, lower the TTL before migrating.
Common mistakes
- Testing DNS with
ping. It hides whether the name lookup or the connection failed. Usedigandgetent. - Forgetting TTLs before a migration.
curl -kin scripts, which quietly accepts any certificate.- Blaming the load balancer for 502s when the app behind it is crashing.
Practice
- Find the IP of
example.comwithdig +short, then ask Google's resolver for the same name. - Read the TTL of the answer.
- Get only the status code of
http://localhost/health. - Check when the certificate on
example.comexpires. - A user reports 504 errors. Where would you look first, and why?
Cheat sheet
| Command | What it does |
|---|---|
dig +short name | Quick DNS answer |
dig @server name TYPE | Ask a specific resolver for a record type |
dig +trace name | Follow the lookup from the root |
getent hosts name | What apps really get |
curl -I url / curl -v url | Headers / the full conversation |
curl -w "%{http_code}" | Status code only |
openssl s_client -connect h:443 | Look at TLS and the certificate |
Key takeaways
- DNS is the phone book: it turns names into IP addresses.
- DNS answers are remembered for a while (the TTL). Lower it before you change a record.
- HTTP codes: 2xx good, 4xx client mistake, 5xx server broke.
- 502, 503 and 504 usually mean the app behind the load balancer has a problem.
- Certificates expire. Renew them automatically and never use
curl -kin real code.