Networking basics
DNS, HTTP, ports, TLS and CORS, the plumbing behind every "it works locally but not in prod" bug.
8 min read · Last reviewed November 20, 2026
Networking basics
Most deployment and integration bugs are really networking bugs. Learning the vocabulary lets you describe the problem precisely, both to an and to yourself.
You'll be able to#
- Explain what happens between typing a URL and seeing a page
- Debug common errors: , DNS, TLS, timeouts, 4xx/5xx
- Set up a custom domain with confidence
The mental model#
example.com → looks up the IP address → the client opens a TCP connection to that IP on port 443 → a handshake encrypts the connection → the client sends an HTTP request → the server sends an HTTP response.
Key concepts#
- IP address: A machine's address on the network. Port: A numbered door on that machine (80 = HTTP, 443 = HTTPS, 5432 = Postgres, 3000 = a typical dev server).
- localhost / 127.0.0.1: "This machine." A server bound to localhost can't be reached from other machines. Binding to
0.0.0.0listens on all interfaces. - DNS records:
A(name → IPv4),AAAA(→ IPv6),CNAME(name → another name),MX(mail),TXT(verification, SPF/DKIM). TTL sets how long resolvers cache a record, which is why DNS changes can seem to "take a while." - HTTP: Methods (
GET,POST,PUT,PATCH,DELETE), headers, body, and status codes:2xxOK,3xxredirect,4xxyour request was wrong (401 not logged in, 403 not allowed, 404 not found, 429 rate-limited),5xxthe server broke. - HTTPS / TLS: Encryption plus proof of identity through certificates. Platforms like Vercel, Netlify and Cloudflare issue certificates automatically (Let's Encrypt).
- CORS: A browser rule. JavaScript on site A can't read responses from site B unless B explicitly allows it with
Access-Control-Allow-Originheaders. Server-to-server calls ignore CORS entirely. - Proxy / reverse proxy / load balancer: Middlemen that forward traffic. Nginx, Caddy and Cloudflare all fill these roles.
- : Servers around the world that cache your static content close to users.
- Firewall / security groups: Rules that decide which ports and IPs can connect.
- WebSockets / SSE: Long-lived connections for real-time updates.
Decisions you make (not the agent)#
Your call, not the agent's
| Decision | Sensible default | Choose otherwise when… |
|---|---|---|
| DNS provider | Your host's DNS or Cloudflare | Your registrar is required for email setup |
| Apex vs www | Serve one, redirect the other | — |
| CORS policy | Allow only your own origins | You're building a public API |
| Database exposure | Private network only, never open to 0.0.0.0/0 | Managed DB with IP allowlist + TLS |
What good output looks like#
- The explanation says which step failed (DNS, connection or port, TLS, HTTP status, or CORS), not just "a network error"
- A CORS fix names specific origins, methods and headers, and never a wildcard when cookies are involved
- It gives you a command to confirm the fix (
dig,curl -I,curl -v) - Nothing weakens TLS or opens a database port to the internet
Red flags#
Access-Control-Allow-Origin: *combined with credentials/cookies- Disabling TLS verification to "fix" an error
- A database port open to the internet
- Treating a CORS error as a server bug. The request often succeeded, and the browser blocked your JavaScript from reading the response.
- Common agent mistakes: "fixing" CORS by allowing every origin, or by reflecting whatever origin the request sends; answering the preflight (
OPTIONS) request incorrectly or not at all; changing DNS records without saying how to check them
Worked example#
Task: A frontend at app.example.com can't call the at api.example.com. The browser console shows a CORS error on a POST that sends JSON and an Authorization header, with cookies enabled.
You paste the error and say "fix CORS." The agent adds Access-Control-Allow-Origin: * to the API's responses. The error remains. It then changes the API to echo back whatever Origin the request sends, and the error goes away.
What a good result contains: the API recognizes the browser's preflight (OPTIONS) request and answers with the one allowed origin, the allowed methods and headers, and Access-Control-Allow-Credentials: true, plus Vary: Origin. Only your own origins are on the allowlist.
The wrong turn: a wildcard isn't allowed on a credentialed request, which is why the first fix failed. The second fix works by accident: echoing back any origin means every website on the internet is now allowed to make credentialed requests to your API.
How review catches it: the request is preflighted because it sends an Authorization header and a JSON body. Reproduce that preflight yourself with curl, and read the response headers. Then repeat it with an origin that is not yours and confirm it is refused. Ask the agent to explain what each header allows. Note that the browser console has the details: JavaScript itself gets no specifics about a CORS failure.
Sample prompts#
I'm getting this error in the browser console when my frontend at <https://app.example.com> calls my API at <https://api.example.com>: <paste error> Explain what's actually happening at the HTTP level, then fix it on the API side, allowing only my frontend origin, with credentials enabled. Don't use a wildcard.
Why it works: It asks for the HTTP-level explanation first, then a narrowly scoped fix: one origin, credentials on, no wildcard. Browsers don't accept a wildcard on credentialed requests, so this is also the fix that works.
Walk me through connecting the domain <example.com> to my <Vercel> project: which DNS records to create at <registrar>, values, apex vs www redirect, and how to verify propagation and TLS from the command line (dig, curl -I).
Why it works: It asks for the exact records and for ways to verify each step from the command line, so you confirm progress instead of waiting and hoping.
Reproduce the preflight with curl#
My browser blocks a POST from https://app.example.com to https://api.example.com/<path>. Use curl to send the preflight request (an OPTIONS request) with the headers Origin, Access-Control-Request-Method: POST and Access-Control-Request-Headers: authorization,content-type. Show me the full response headers and tell me which CORS header is missing or wrong. Then repeat it with Origin: https://evil.example and show that it is refused.
Why it works: It tests the server directly, the way the browser would, and the second request proves the fix isn't too permissive.
Find the layer that is failing#
<describe the symptom: site doesn't load / API call fails>. Diagnose it layer by layer: DNS (dig), connection and port (curl -v), TLS (curl -v, certificate), HTTP status, and CORS (browser console only). For each layer give the exact command, what a healthy result looks like, and what a failure means. Run what you can and tell me which layer fails first.
Why it works: Most "network" bugs are one specific layer. Checking in order stops you from debugging CORS when the real problem is DNS.
Explain why your CORS config is safe#
Explain the CORS configuration you just wrote: which origins, methods, headers and credentials it allows, and why each is necessary. What could a malicious website do against this API with this config? If any answer is "more than it should", tighten it.
Why it works: It makes the agent justify every permission. Check the answer against the actual response headers from curl.
Check your understanding#
Check your understanding
Checklist#
- DNS records exist and
digshows the expected values - HTTPS works, the certificate is valid, and HTTP redirects to HTTPS
- Either the apex domain or
wwwredirects to the other - CORS allows only my own origins, and there is no wildcard when cookies are involved
- The database is not reachable from the open internet
- I know how to test the fix with
curl -Iorcurl -v
Go deeper#
- MDN: An overview of HTTP
- MDN: CORS
- How DNS works (comic)
- How software fits together: where these requests sit in the whole picture
- Security basics: , secrets and exposure