HTTP Status Codes Explained: 40+ HTTP Status Codes Every Developer Should Know

When a browser opens a website or an application sends a request to an API, the server returns an HTTP response. One of the most important pieces of that response is the HTTP status code.

You have probably seen codes such as 200 OK, 404 Not Found, 401 Unauthorized, or 500 Internal Server Error.

These codes help clients, developers, monitoring systems, and API consumers understand what happened to a request.

Simple Definition: An HTTP status code is a three-digit number returned by an HTTP server to indicate the result or current state of a request.

Why Are HTTP Status Codes Important?

Status codes provide a standardized way for servers to communicate outcomes.

For example:

GET /api/users/25
        |
        v
   HTTP Server
        |
        v
200 OK
  

A client can use the status code to decide whether a request succeeded, requires another action, failed because of invalid input, or failed because of a server-side problem.

The Five Main HTTP Status Code Classes

HTTP status codes are grouped into five classes based on their first digit.

Range Class General Meaning
100–199 Informational Request received or processing information
200–299 Success Request was successfully handled
300–399 Redirection Further action may be required
400–499 Client Error Request could not be fulfilled due to a client-side issue
500–599 Server Error Server encountered a problem processing the request

HTTP Status Codes Cheat Sheet

Code Meaning Common Use
100ContinueInterim response
101Switching ProtocolsProtocol upgrade
200OKSuccessful request
201CreatedResource created
202AcceptedRequest accepted for processing
204No ContentSuccessful response without a body
301Moved PermanentlyPermanent redirect
302FoundTemporary redirect
304Not ModifiedConditional request has no newer representation
307Temporary RedirectTemporary redirect preserving method
308Permanent RedirectPermanent redirect preserving method
400Bad RequestMalformed or invalid request
401UnauthorizedAuthentication required or failed
403ForbiddenRequest understood but not permitted
404Not FoundResource not found
405Method Not AllowedHTTP method not supported for resource
408Request TimeoutServer timed out waiting for request
409ConflictConflict with resource state
410GoneResource intentionally no longer available
413Content Too LargeRequest body exceeds permitted size
415Unsupported Media TypeUnsupported request format
422Unprocessable ContentContent understood but cannot be processed
429Too Many RequestsRate limit exceeded
500Internal Server ErrorUnexpected server failure
501Not ImplementedServer does not support required functionality
502Bad GatewayGateway received an invalid upstream response
503Service UnavailableService temporarily unavailable
504Gateway TimeoutGateway timed out waiting for upstream

1xx Informational Status Codes

100-level status codes are informational responses. They generally indicate that the request has been received and processing can continue.

100 Continue

The server indicates that the initial part of the request has been received and the client can continue sending the request.

101 Switching Protocols

This response indicates that the server agrees to switch to a different protocol according to the client's request.



2xx Success Status Codes

200-level status codes indicate successful handling of a request.

200 OK

200 OK is one of the most commonly encountered HTTP status codes.

It generally indicates that the request was successfully processed.

Example:

GET /api/users/25

HTTP/1.1 200 OK
  

201 Created

201 Created indicates that a new resource has been created successfully.

It is commonly used after POST requests that create resources.

POST /api/users

HTTP/1.1 201 Created
  

202 Accepted

202 Accepted indicates that the request has been accepted for processing, but processing may not be complete yet.

This can be useful for asynchronous operations.

204 No Content

204 No Content indicates successful processing when the response does not need to contain a message body.

For example, an API might return 204 after successfully deleting a resource.

3xx Redirection Status Codes

300-level status codes indicate that additional action may be required to complete a request.

301 Moved Permanently

301 indicates that a resource has been permanently moved to a different location.

Example:

https://example.com/old-page
        ↓
https://example.com/new-page
  

302 Found

302 Found indicates a temporary redirection in modern HTTP usage.

304 Not Modified

304 Not Modified is used with conditional requests. It tells the client that its cached representation can still be used because the resource has not changed according to the request's conditions.

307 Temporary Redirect

307 Temporary Redirect indicates a temporary redirect while preserving the request method and request body semantics.

308 Permanent Redirect

308 Permanent Redirect indicates a permanent redirect while preserving the request method and request body semantics.

4xx Client Error Status Codes

400-level responses generally indicate a problem with the request from the client side. That does not necessarily mean the person using the client made a mistake; it means the request cannot be fulfilled due to the request or its context.

400 Bad Request

400 Bad Request is commonly returned when the server cannot process a malformed or invalid request.

Example:

POST /api/users

{
  "email": 
}
  

The request body is malformed, so the server may return 400.

401 Unauthorized

401 Unauthorized is commonly used when valid authentication credentials are required but are missing or invalid.

Example:

GET /api/profile

HTTP/1.1 401 Unauthorized
  

Important: The name can be confusing. In API security discussions, 401 generally relates to authentication, not simply permission.

403 Forbidden

403 Forbidden indicates that the server understood the request but refuses to authorize it.

For example, a normal user may authenticate successfully but still receive 403 when trying to access an administrator-only resource.

404 Not Found

404 Not Found means that the server cannot find a current representation for the requested resource.

Example:

GET /api/users/99999

404 Not Found
  

405 Method Not Allowed

405 Method Not Allowed indicates that the request method is known by the server but is not allowed for the requested resource.

For example, an endpoint might support GET but not DELETE.

408 Request Timeout

408 Request Timeout indicates that the server did not receive a complete request within the time it was prepared to wait.

409 Conflict

409 Conflict indicates that the request conflicts with the current state of the target resource.

For example, an API could use 409 when attempting to create a resource that conflicts with an existing unique record, depending on the API design.

410 Gone

410 Gone indicates that the requested resource is no longer available and that the condition is likely to be permanent.

413 Content Too Large

413 Content Too Large indicates that the request content exceeds a limit defined by the server.

This can occur when uploading a file or sending a large request body.

415 Unsupported Media Type

415 Unsupported Media Type indicates that the server does not support the media format of the request.

For example, an endpoint expecting JSON might reject an unsupported request format.

422 Unprocessable Content

422 Unprocessable Content indicates that the server understood the content type and syntax but could not process the contained instructions or data.

For example, a request might contain valid JSON but fail application-level validation.

429 Too Many Requests

429 Too Many Requests is commonly used when the client has sent too many requests within a defined period.

This is especially relevant to APIs that implement rate limiting.

5xx Server Error Status Codes

500-level status codes generally indicate a problem on the server side while processing a valid request.

500 Internal Server Error

500 indicates an unexpected server-side error.

Example:

GET /api/orders

HTTP/1.1 500 Internal Server Error
  

Possible causes include:

  • Unhandled application exceptions
  • Unexpected dependency failures
  • Programming errors
  • Configuration problems

501 Not Implemented

501 Not Implemented indicates that the server does not support the functionality required to fulfill the request.

502 Bad Gateway

502 Bad Gateway usually occurs when a server acting as a gateway or proxy receives an invalid response from an upstream server.

Client
  |
  v
Reverse Proxy
  |
  v
Application Server
  |
  X
Invalid / Failed Response

Proxy → 502
  

503 Service Unavailable

503 Service Unavailable indicates that the server is currently unable to handle the request, often due to temporary overload, maintenance, or another temporary condition.

504 Gateway Timeout

504 Gateway Timeout indicates that a gateway or proxy did not receive a timely response from an upstream server.

Client
  |
  v
Gateway
  |
  v
Backend
  |
  |
  |------ No timely response
  |
Gateway → 504
  

401 vs 403: What Is the Difference?

This is one of the most common interview questions.

401 403
Authentication is missing or invalid Request is understood but not authorized
Identity has not been successfully established Identity may be known, but access is denied
Example: expired or missing credentials Example: normal user requesting admin-only data

404 vs 410

Both codes relate to missing resources, but their meaning differs.

404 Not Found indicates that the server cannot find a current representation for the resource.

410 Gone indicates that the resource is no longer available and that this is intended to be permanent.

500 vs 502 vs 503 vs 504

Code Typical Problem
500 Unexpected internal server problem
502 Gateway/proxy received an invalid upstream response
503 Service temporarily unavailable
504 Gateway/proxy timed out waiting for upstream

HTTP Status Codes in REST APIs

Correct status codes make REST APIs easier to understand and consume.

For example:

GET    /users/10      → 200
POST   /users         → 201
PATCH  /users/10      → 200 or 204
DELETE /users/10      → 204
GET    /users/999     → 404
POST   /users         → 400 / 422
GET    /admin/report  → 401 / 403
GET    /users         → 429
GET    /users         → 500
  

The exact status selected depends on the semantics of the API and its application rules.

HTTP Status Codes and Frontend Applications

Frontend applications can use status codes to decide what to display or what action to perform.

For example:

if (response.status === 200) {
    // Show data
}

if (response.status === 401) {
    // Ask user to log in
}

if (response.status === 403) {
    // Show access denied message
}

if (response.status === 404) {
    // Show not found message
}

if (response.status === 500) {
    // Show generic server error
}
  

This allows applications to handle different outcomes more intelligently.

HTTP Status Codes and JavaScript Fetch

One important detail is that the Fetch API does not automatically reject a promise merely because an HTTP response has a 4xx or 5xx status.

Developers should inspect the response status or the ok property.

fetch("/api/users")
  .then(response => {
    if (!response.ok) {
      throw new Error(`HTTP ${response.status}`);
    }

    return response.json();
  })
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
  

HTTP Status Codes and API Error Handling

A good API should combine an appropriate status code with a useful response body when additional information is appropriate.

For example:

HTTP/1.1 422 Unprocessable Content
Content-Type: application/json

{
  "error": "validation_error",
  "message": "Email address is invalid",
  "field": "email"
}
  

This is generally more useful to a frontend than returning only a number.

Should You Use 200 for Every API Response?

Using 200 for every situation is generally a poor API design choice.

Status codes exist to communicate meaningful outcomes.

For example, returning 200 for a failed authentication attempt makes it harder for clients, monitoring tools, developers, and intermediaries to understand what happened.

Use status codes according to the semantics of the operation and your API design.

How Developers Debug HTTP Status Codes

When an application returns an unexpected status code, inspect the complete request and response.

Useful information includes:

  • HTTP method
  • Request URL
  • Request headers
  • Request body
  • Status code
  • Response headers
  • Response body
  • Server logs
  • Reverse-proxy logs
  • Application logs

Browser developer tools, Postman, curl, server logs, and monitoring systems can all help identify the cause.

Example: Debugging a 404

Suppose your frontend requests:

GET /api/user/25
  

but the API actually defines:

GET /api/users/25
  

The difference between user and users could result in a 404.

Always check the actual endpoint, routing configuration, base URL, and deployment environment.

Example: Debugging a 401

Suppose a protected endpoint returns 401.

Check:

  1. Whether credentials were included.
  2. Whether the credentials are valid.
  3. Whether the expected authentication scheme was used.
  4. Whether the token has expired.
  5. Whether the server received the authentication header.

Example: Debugging a 403

If authentication succeeds but the server returns 403, inspect authorization rules.

Common questions include:

  • Does the user have the required role?
  • Does the account have the required permission?
  • Is the requested resource restricted?
  • Is a policy blocking the action?

Example: Debugging a 502

A 502 often points to a problem between a proxy and an upstream service.

Browser
   |
   v
Nginx / Reverse Proxy
   |
   v
Node.js / Python / PHP Backend
  

Possible causes can include:

  • Backend process stopped
  • Incorrect upstream address
  • Connection failure
  • Malformed upstream response
  • Deployment problem

Example: Debugging a 503

A 503 can indicate that a service is temporarily unavailable.

Possible causes include:

  • Maintenance
  • Application overload
  • Unavailable backend service
  • Health-check failure
  • Deployment transition

Example: Debugging a 504

A 504 usually means a gateway or proxy waited for an upstream response but did not receive one within the relevant timeout.

Investigate:

  • Backend response time
  • Database performance
  • Network connectivity
  • Proxy timeout configuration
  • Long-running operations

HTTP Status Codes Interview Questions

What does HTTP 200 mean?

It generally means that the request was successfully processed.

What does HTTP 201 mean?

It indicates that a resource was successfully created.

What does HTTP 204 mean?

It indicates successful processing with no response content.

What does HTTP 301 mean?

It indicates that a resource has been permanently moved to another location.

What does HTTP 304 mean?

It indicates that the client's cached representation can be reused because the resource has not changed according to the conditional request.

What does HTTP 400 mean?

It generally indicates that the server could not process the request because it was invalid or malformed.

What is the difference between 401 and 403?

401 generally relates to missing or invalid authentication, while 403 means the request is understood but access is not permitted.

What does HTTP 404 mean?

It means that the requested resource could not be found.

What does HTTP 429 mean?

It indicates that the client has sent too many requests within a relevant time period.

What does HTTP 500 mean?

It indicates an unexpected internal server error.

What does HTTP 502 mean?

It generally indicates that a gateway or proxy received an invalid response from an upstream server.

What does HTTP 503 mean?

It indicates that the server is currently unable to handle the request, often because of a temporary condition.

What does HTTP 504 mean?

It indicates that a gateway or proxy did not receive a timely response from an upstream server.

Frequently Asked Questions

```

What are HTTP status codes?

HTTP status codes are three-digit numbers returned in HTTP responses to communicate the result or state of a request.

How many categories of HTTP status codes are there?

There are five categories: informational (1xx), success (2xx), redirection (3xx), client error (4xx), and server error (5xx).

Which HTTP status code means success?

200 OK is the most common success status code, although other successful codes such as 201 and 204 are used for specific situations.

Which HTTP status code means not found?

404 Not Found indicates that the server cannot find the requested resource.

What is the difference between 401 and 403?

401 generally indicates an authentication problem, while 403 indicates that the request is not authorized.

What does 429 mean?

429 Too Many Requests indicates that a client has exceeded an applicable request rate limit.

What is the difference between 500 and 503?

500 generally indicates an unexpected internal server error, while 503 indicates that the service is currently unavailable and may recover later.

What causes a 502 error?

A 502 often occurs when a gateway or reverse proxy receives an invalid response from an upstream server.

What causes a 504 error?

A 504 occurs when a gateway or proxy waits for an upstream server but does not receive a response within the relevant timeout.

Are HTTP status codes only used for websites?

No. They are also widely used by APIs, backend services, mobile applications, cloud services, proxies, and other HTTP-based systems.

```

Final Thoughts

HTTP status codes are a fundamental part of web development, backend programming, API design, DevOps, and cybersecurity.

You do not need to memorize every status code immediately. Start with the most useful ones:

200  → Success
201  → Created
204  → No Content

301  → Permanent Redirect
302  → Temporary Redirect
304  → Not Modified

400  → Bad Request
401  → Authentication Problem
403  → Forbidden
404  → Not Found
405  → Method Not Allowed
409  → Conflict
422  → Unprocessable Content
429  → Too Many Requests

500  → Internal Server Error
502  → Bad Gateway
503  → Service Unavailable
504  → Gateway Timeout
  

Once these codes become familiar, debugging web applications and REST APIs becomes much easier.

CodeWithAV Developer Tip:

When debugging an API, never look only at the status code. Inspect the request URL, method, headers, body, response body, server logs, and upstream services together.

Related Articles on CodeWithAV

What Is an API? Complete Beginner Guide

REST API Explained With Examples

What Is JSON?

HTTP vs HTTPS Explained

How a Website Works From Browser to Server

Explore More Web Development and Networking Guides

Disclosure: Some links on CodeWithAV may be affiliate links. If you purchase a product or service through an affiliate link, we may earn a commission at no additional cost to you. We aim to recommend products and services based on their relevance to our readers.

CodeWithAV — Learn, Discover & Build.

Adarsh verma

Adarsh verma

CodeWithAV publishes practical technology tutorials, study resources, programming guides, and cybersecurity learning content.

HTTP vs HTTPS Explained: Difference, Security, Ports & How HTTPS Works

Whenever you open a website, your browser communicates with a server using network protocols. Two terms that frequently appear in web development and cybersecurity are HTTP and HTTPS.

You have probably noticed addresses such as:

http://example.com
https://example.com
  

They look almost identical, but the difference is extremely important.

HTTP stands for Hypertext Transfer Protocol, while HTTPS stands for Hypertext Transfer Protocol Secure.

HTTPS adds cryptographic protection to HTTP communication, helping protect data exchanged between the client and server.

Simple Definition: HTTP transfers web data without the transport encryption provided by HTTPS. HTTPS uses HTTP over a secure TLS connection to protect data in transit.


What Is HTTP?

HTTP is a protocol used for communication between web clients and servers.

When you open a website, your browser can send an HTTP request to a server. The server processes that request and sends an HTTP response.

Browser
   |
   | HTTP Request
   v
Web Server
   |
   | HTTP Response
   v
Browser
  

HTTP is the foundation for exchanging resources such as HTML documents, stylesheets, JavaScript files, images, and API responses.

What Is HTTPS?

HTTPS is HTTP carried over a secure TLS connection.

TLS stands for Transport Layer Security.

HTTPS is designed to provide important security properties for data sent between a client and server, including:

  • Encryption of data in transit
  • Integrity protection
  • Authentication of the server through certificates
Browser
   |
   | Encrypted TLS Connection
   v
Web Server
   |
   | Encrypted TLS Connection
   v
Browser
  

HTTP vs HTTPS at a Glance

Feature HTTP HTTPS
Protocol HTTP HTTP over TLS
Encryption in transit No TLS protection Yes, through TLS
Typical port 80 443
Server authentication No TLS certificate authentication Uses TLS certificates
Data integrity protection Not provided by TLS Provided by TLS

Why Is HTTPS Important?

When sensitive information travels across a network, an attacker who can observe network traffic should not be able to simply read or modify the protected contents.

HTTPS helps protect information such as:

  • Login credentials
  • Session cookies
  • Personal information
  • Payment-related information
  • API requests and responses
  • Private application data

HTTPS is therefore an important part of modern web security.

How Does HTTPS Work?

HTTPS uses TLS to create a protected communication channel between the client and server.

A simplified flow looks like this:

1. Browser connects to website
             ↓
2. Server presents its TLS certificate
             ↓
3. Browser validates the certificate
             ↓
4. Client and server establish cryptographic keys
             ↓
5. Secure TLS connection is established
             ↓
6. HTTP messages travel through that connection
  

The exact cryptographic process is more detailed, but this simplified model helps beginners understand the purpose of TLS.

What Is TLS?

TLS stands for Transport Layer Security.

TLS is a cryptographic protocol designed to secure communication over networks.

HTTPS uses TLS to protect HTTP traffic.

So the relationship can be visualized as:

HTTPS
  |
  +-- HTTP
  |
  +-- TLS protection
  |
  +-- Secure network connection
  

What Is an SSL Certificate?

You may often hear people say SSL certificate when discussing website security.

SSL stands for Secure Sockets Layer. SSL is an older protocol that has been replaced by TLS for modern secure web communication.

The term "SSL certificate" is still widely used to describe the digital certificates used with HTTPS, even though modern systems use TLS rather than the old SSL protocol.

What Is a TLS Certificate?

A TLS certificate is a digital certificate associated with a website's identity and public key.

It helps a browser verify that the server it is connecting to is associated with the requested domain, subject to the certificate validation process and trust model.

Certificates are issued by trusted certificate authorities within the browser or operating system trust ecosystem.

What Does a Browser Check in a Certificate?

Certificate validation involves several checks. Depending on the environment, the browser can verify items such as:

  • The certificate is valid for the requested domain.
  • The certificate is currently within its validity period.
  • The certificate chains to a trusted authority.
  • The certificate has not failed other required validation checks.

If a serious certificate validation problem exists, the browser can warn the user before establishing normal HTTPS trust.

What Is Encryption?

Encryption transforms readable information into a form that cannot be understood without the appropriate cryptographic information needed to decrypt or authenticate it.

For example, a message such as:

Hello Server
  

can be transmitted as protected ciphertext rather than as ordinary readable text.

Modern TLS uses established cryptographic algorithms to provide confidentiality and integrity protection.

What Is Data Integrity?

Integrity means detecting unauthorized modification of data during transmission.

Imagine sending:

amount=1000
  

An attacker should not be able to silently change it to:

amount=9000
  

without the communication endpoints detecting that something went wrong.

TLS provides integrity protection for the protected connection.

What Is Authentication in HTTPS?

HTTPS uses certificates to help authenticate the server.

This is important because encryption by itself is not enough.

Suppose an attacker creates a fake website that looks exactly like a legitimate website. A secure connection alone would not prove that the website is the correct site unless the authentication and certificate checks are also valid.

TLS certificate validation helps the browser establish that the server is associated with the requested domain according to the certificate trust system.

HTTP Port 80 vs HTTPS Port 443

HTTP is conventionally associated with TCP port 80.

HTTPS is conventionally associated with TCP port 443.

HTTP
Browser
   |
   +---- TCP 80 ----> Web Server


HTTPS
Browser
   |
   +---- TCP 443 ---> Web Server
          |
          +---- TLS
  

These are conventional ports, not absolute requirements. Network services can be configured differently.

HTTP Example

A simplified HTTP request could look like:

GET /index.html HTTP/1.1
Host: example.com
  

The server might return:

HTTP/1.1 200 OK
Content-Type: text/html
  

With ordinary HTTP, there is no TLS layer protecting the communication.

HTTPS Example

With HTTPS, HTTP messages are carried inside a TLS-protected connection.

Browser
   |
   | TLS-secured connection
   v
Server

Inside the protected connection:
HTTP Request
HTTP Response
  

The network does not simply see the HTTP application data as ordinary plaintext.

Does HTTPS Encrypt Everything?

No.

HTTPS protects the contents of the TLS connection, but it does not make every aspect of network activity invisible.

For example, information such as IP addresses and certain metadata can still be observable to parts of the network infrastructure.

HTTPS should therefore not be interpreted as complete anonymity.

Can HTTPS Stop All Cyberattacks?

No.

HTTPS protects data in transit, but it does not automatically protect the website from vulnerabilities in its own application or infrastructure.

A website can use HTTPS and still have problems such as:

  • Weak passwords
  • Broken access control
  • SQL injection
  • Cross-site scripting
  • Insecure file uploads
  • Server misconfiguration
  • Vulnerable dependencies
  • Compromised user accounts

HTTPS is one layer of security, not a complete security solution.

HTTPS and Public Wi-Fi

Public Wi-Fi networks can expose users to security risks when applications communicate without adequate transport protection.

HTTPS helps protect the content of web communication from network observers by encrypting the traffic between the client and server.

However, users should still be careful with suspicious websites, phishing pages, malicious downloads, and compromised accounts.

What Is a Man-in-the-Middle Attack?

A Man-in-the-Middle (MITM) attack occurs when an attacker places themselves between two communicating parties and attempts to observe, modify, or interfere with their communication.

TLS helps defend against network-level interception and modification by providing encryption, integrity, and server authentication.

Without Proper Transport Protection

Client <------> Attacker <------> Server
                 |
              Can attempt
             to observe or
              alter traffic


With Proper HTTPS

Client ======== TLS ========= Server
        Protected Connection
  

HTTPS does not protect against every form of attack, but it significantly improves the security of data in transit.

HTTP Redirect to HTTPS

Many websites configure HTTP traffic to redirect users to an HTTPS URL.

For example:

http://example.com
       |
       v
https://example.com
  

A redirect can help move users toward the secure version of a site.

However, the initial HTTP connection is not itself protected by TLS, so secure-site configurations often also use mechanisms such as HSTS to tell compatible browsers to use HTTPS for future connections.

What Is HSTS?

HSTS stands for HTTP Strict Transport Security.

HSTS is a browser security mechanism that allows a website to tell compatible browsers that it should only be accessed through HTTPS for a specified period.

A response can include a header such as:

Strict-Transport-Security: max-age=31536000
  

Real deployment should use HSTS deliberately and according to the site's infrastructure and domain configuration.

HTTPS and Cookies

HTTPS is especially important for applications that use authentication cookies or session information.

Websites can also configure cookie security attributes such as:

  • Secure — directs browsers to send the cookie over secure connections.
  • HttpOnly — helps prevent client-side scripts from directly reading the cookie.
  • SameSite — controls how cookies are sent in cross-site contexts.

These controls complement HTTPS rather than replacing it.

HTTPS and APIs

APIs often handle valuable information, making transport security extremely important.

A secure API might use:

https://api.example.com/users
  

Instead of:

http://api.example.com/users
  

When API requests contain authentication credentials or private information, transmitting them over an unprotected connection can expose those credentials and data to network attackers.

HTTPS in Mobile Applications

Mobile applications also communicate with remote APIs.

A mobile app might send:

POST https://api.example.com/login
  

The TLS connection helps protect the credentials and other application data in transit.

Does HTTPS Affect Website Speed?

Modern TLS implementations are designed to minimize connection overhead, and HTTPS is standard practice for modern websites.

The overall performance of a website depends on many factors, including:

  • Server response time
  • Network latency
  • HTTP protocol version
  • Image sizes
  • JavaScript and CSS
  • Caching
  • Content delivery architecture

Therefore, HTTPS should not be viewed simply as a feature that automatically makes a site slow.

HTTPS and SEO

Website security is important for users and modern web infrastructure. Search engines may also use HTTPS as a ranking-related signal in their systems.

However, switching a website to HTTPS does not guarantee higher search rankings. Content quality, relevance, technical health, user experience, and many other factors also matter.

How to Check Whether a Website Uses HTTPS

Look at the browser's address bar.

A website using HTTPS will generally begin with:

https://
  

Modern browsers may display security information differently, so the exact visual indicator can vary between browsers.

How to Inspect a Website Certificate

Most modern browsers provide certificate and connection details through the site's security information in the address bar or developer tools.

You can use this information to inspect details such as:

  • Certificate subject
  • Certificate issuer
  • Validity period
  • Connection security

HTTP vs HTTPS: Security Comparison

Security Property HTTP HTTPS
Confidentiality No TLS encryption Protected by TLS
Integrity No TLS integrity protection TLS provides integrity protection
Server Authentication No TLS certificate mechanism TLS certificates support authentication

Common HTTPS Misconceptions

Misconception 1: HTTPS Means the Website Is Completely Safe

Not necessarily. HTTPS protects transport between endpoints, but the website can still contain application vulnerabilities.

Misconception 2: HTTPS Means the Website Owner Is Trustworthy

A valid certificate primarily helps authenticate control of the relevant domain within the certificate trust system. It does not guarantee that the site's content, business practices, or offers are trustworthy.

Misconception 3: HTTPS Provides Complete Anonymity

No. HTTPS protects application data in the encrypted connection, but network metadata can still reveal information such as IP addresses and traffic patterns.

Misconception 4: HTTPS Is Only Needed for Payment Websites

HTTPS is useful for all kinds of websites and applications because even ordinary browsing can involve cookies, account credentials, personal data, and private application information.

How Developers Can Enable HTTPS

The exact process depends on the hosting environment, reverse proxy, platform, and certificate setup.

A typical deployment process can include:

  1. Configure the domain.
  2. Obtain a trusted TLS certificate.
  3. Configure the web server or hosting platform.
  4. Enable HTTPS.
  5. Test certificate validation.
  6. Redirect appropriate HTTP traffic to HTTPS.
  7. Configure secure cookies and application settings.
  8. Consider HSTS after the HTTPS configuration is correct.

HTTPS With Nginx

On Linux servers, Nginx is commonly used as a web server or reverse proxy.

A simplified configuration might look conceptually like:

server {
    listen 443 ssl;
    server_name example.com;

    ssl_certificate     /path/to/certificate.pem;
    ssl_certificate_key /path/to/private-key.pem;

    location / {
        proxy_pass http://127.0.0.1:3000;
    }
}
  

This is only a conceptual example. Production TLS configuration should follow current security guidance for the specific server and environment.

HTTPS for Bloggers and Website Owners

If you run a blog, portfolio, business website, or application, HTTPS should be treated as a basic security requirement.

Before publishing a website, check:

  • The site loads using HTTPS.
  • The certificate is valid.
  • Important pages do not expose sensitive data over HTTP.
  • Authentication cookies use appropriate security attributes.
  • Mixed-content issues are resolved.

What Is Mixed Content?

Mixed content occurs when an HTTPS page tries to load some resources using HTTP.

For example:

HTTPS page
   |
   +-- HTTPS image  ✓
   +-- HTTPS CSS    ✓
   +-- HTTP script  ✗
  

Modern browsers may block or restrict insecure resources because loading them over an unprotected connection can weaken the security of an HTTPS page.

HTTP/2 and HTTP/3

HTTPS should also be distinguished from HTTP versions.

HTTP/1.1, HTTP/2, and HTTP/3 are versions of the HTTP protocol or related transport architecture.

HTTPS describes the use of HTTP through a secure TLS-protected connection. HTTP/3 uses QUIC as its transport and incorporates TLS security as part of the protocol design.

Therefore:

HTTP vs HTTPS
     =
Security / transport protection concept

HTTP/1.1 vs HTTP/2 vs HTTP/3
     =
HTTP protocol versions
  

Frequently Asked Questions

```

What is the difference between HTTP and HTTPS?

HTTP is the standard web communication protocol, while HTTPS is HTTP carried over a TLS-protected connection that provides encryption, integrity protection, and server authentication.

What does HTTPS stand for?

HTTPS stands for Hypertext Transfer Protocol Secure.

What does HTTP stand for?

HTTP stands for Hypertext Transfer Protocol.

What port does HTTP use?

HTTP is conventionally associated with TCP port 80.

What port does HTTPS use?

HTTPS is conventionally associated with TCP port 443.

Is HTTPS encrypted?

Yes. HTTPS uses TLS to encrypt and protect application data sent through the secure connection.

What is SSL?

SSL stands for Secure Sockets Layer. It is an older security protocol that has been replaced by TLS. The term "SSL certificate" remains common in everyday usage.

What is TLS?

TLS stands for Transport Layer Security. It is the cryptographic protocol used by modern HTTPS connections.

Does HTTPS prevent hacking?

No. HTTPS protects data in transit but does not eliminate application vulnerabilities, compromised accounts, insecure configurations, or other security risks.

Can HTTPS protect passwords?

HTTPS helps protect passwords while they are transmitted between the browser or application and the server. The application must still securely store and process passwords.

Does HTTPS make a website trustworthy?

No. HTTPS helps authenticate the website's domain through the certificate system, but it does not guarantee the trustworthiness of the site's content, owner, products, or services.

What is an HTTPS certificate?

A TLS certificate is a digital certificate used as part of the HTTPS trust and authentication process.

```

Final Thoughts

The difference between HTTP and HTTPS is more than one extra letter in a website address.

HTTP provides the basic mechanism for transferring web resources, while HTTPS adds TLS protection to the communication channel.

HTTPS helps provide three important security properties: confidentiality, integrity, and server authentication.

For modern website owners, developers, and cybersecurity learners, understanding HTTPS is essential because secure transport is a fundamental layer of web security.

CodeWithAV Security Reminder:

Use HTTPS for websites and APIs, protect authentication credentials, validate certificates, configure secure cookies, remove mixed content, and remember that transport security is only one part of overall application security.

Related Articles on CodeWithAV

What Is JSON? Complete Beginner Guide

REST API Explained With Examples

What Is the Internet and How Does It Work?

How a Website Works From Browser to Server

Explore More Cybersecurity and Web Development Guides

Disclosure: Some links on CodeWithAV may be affiliate links. If you purchase a product or service through an affiliate link, we may earn a commission at no additional cost to you. We aim to recommend products and services based on their relevance to our readers.

CodeWithAV — Learn, Discover & Build.

Adarsh verma

Adarsh verma

CodeWithAV publishes practical technology tutorials, study resources, programming guides, and cybersecurity learning content.

REST API Explained With Examples: Complete Beginner Guide

REST APIs are one of the most common ways modern web applications communicate with backend systems.

When a frontend application loads user information, creates an order, updates a profile, or deletes a task, it may communicate with a backend through a REST-style API.

For beginners, REST can initially seem complicated because it involves terms such as resources, endpoints, HTTP methods, statelessness, JSON, status codes, authentication, and CRUD operations.

This guide explains REST APIs step by step with simple examples so that you can understand the concepts and start building your own APIs.

Simple Definition: A REST API is a web API designed according to principles of the REST architectural style, typically using HTTP methods to interact with resources.

What Does REST Stand For?

REST stands for Representational State Transfer.

REST was introduced as an architectural style for designing networked systems. It is not a programming language, framework, or protocol.

REST APIs commonly use the existing HTTP protocol to expose and manipulate resources.

What Is a REST API?

A REST API provides an interface that allows clients to communicate with server-side resources using HTTP.

The client can be:

  • A web browser
  • A React application
  • A mobile application
  • A desktop application
  • Another backend service
  • A command-line program

The server may contain:

  • Business logic
  • Databases
  • Authentication systems
  • File storage
  • External service integrations
Client
  |
  | HTTP Request
  v
REST API
  |
  v
Application Logic
  |
  v
Database
  |
  v
REST API
  |
  | HTTP Response
  v
Client
  

What Is a Resource in REST?

A resource is an important concept in REST.

A resource can represent something that the application manages, such as:

  • Users
  • Products
  • Orders
  • Students
  • Courses
  • Blog posts
  • Comments
  • Tasks

For example, in a student management system, students could be a resource.

An endpoint might be:

/api/students
  

A specific student could be identified by:

/api/students/101
  

REST API Endpoint Examples

Suppose we are building an online store.

Possible resource endpoints could be:

/api/products
/api/products/25
/api/users
/api/users/15
/api/orders
/api/orders/500
  

The URL identifies the resource being accessed.

HTTP Methods in REST APIs

REST APIs commonly use HTTP methods to indicate what operation the client wants to perform.

GET

GET is generally used to retrieve a resource.

GET /api/products
  

This could return a collection of products.

To retrieve one product:

GET /api/products/25
  

POST

POST is commonly used to submit data or create a resource.

POST /api/products
  

The request body might contain:

{
  "name": "Wireless Keyboard",
  "price": 1499
}
  

PUT

PUT is commonly used to replace the representation of a resource.

PUT /api/products/25
  

A complete replacement representation might look like:

{
  "name": "Mechanical Keyboard",
  "price": 2499
}
  

PATCH

PATCH is commonly used when only part of a resource needs to be modified.

PATCH /api/products/25
  

The client may send only the field that needs to change:

{
  "price": 2299
}
  

DELETE

DELETE is generally used to remove a resource.

DELETE /api/products/25
  

REST and CRUD Operations

REST APIs are frequently designed around CRUD operations.

CRUD stands for:

  • Create
  • Read
  • Update
  • Delete
CRUD HTTP Method Example
Create POST POST /api/users
Read GET GET /api/users/15
Update PUT/PATCH PATCH /api/users/15
Delete DELETE DELETE /api/users/15

REST API Example: Student Management System

Let's design a small REST API for students.

Get All Students

GET /api/students
  

Possible response:

[
  {
    "id": 1,
    "name": "Rahul",
    "course": "MCA"
  },
  {
    "id": 2,
    "name": "Anita",
    "course": "BCA"
  }
]
  

Get One Student

GET /api/students/1
  

Create a Student

POST /api/students
  

Request body:

{
  "name": "Aman",
  "course": "MCA"
}
  

Update a Student

PATCH /api/students/1
  

Request body:

{
  "course": "MCA 2nd Year"
}
  

Delete a Student

DELETE /api/students/1
  

What Is Statelessness in REST?

Statelessness is one of the important REST constraints.

In a stateless interaction, each request contains the information needed by the server to understand and process that request. The server does not rely on storing client session state between requests as part of the REST interaction.

For example, an authenticated API request might contain a token:

Authorization: Bearer YOUR_ACCESS_TOKEN
  

The server can use the supplied credential to identify and authorize the request according to its authentication system.

Why Is Statelessness Useful?

Stateless APIs can make horizontal scaling easier because requests do not necessarily need to be routed back to one specific application server to recover local session state.

However, real systems may use supporting infrastructure such as shared session stores, caches, databases, or gateways. Statelessness describes how the API interaction is designed, not a promise that no state exists anywhere in the entire application.

JSON in REST APIs

JSON is a common format for REST API requests and responses.

Example response:

{
  "id": 101,
  "name": "Adarsh",
  "role": "Developer",
  "skills": [
    "JavaScript",
    "Python",
    "SQL"
  ]
}
  

The server can generate this response and the frontend can parse it into application data.

HTTP Status Codes in REST APIs

REST APIs should use appropriate HTTP status codes to communicate the outcome of requests.

Status Common Meaning Typical Example
200 OK Successful GET or update response
201 Created New resource created
204 No Content Successful operation with no response body
400 Bad Request Invalid request data
401 Unauthorized Missing or invalid authentication
403 Forbidden Authenticated but not allowed
404 Not Found Resource does not exist
409 Conflict Request conflicts with current resource state
429 Too Many Requests Rate limit exceeded
500 Internal Server Error Unexpected server-side failure

What Are REST API Headers?

HTTP headers provide metadata about requests and responses.

Common examples include:

Content-Type: application/json
Accept: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
  

Content-Type tells the server what format the request body uses.

Accept can indicate the response formats the client can process.

Authorization can carry authentication credentials when the API's security design uses them.

Path Parameters vs Query Parameters

Path Parameters

Path parameters identify a specific resource or part of a resource path.

GET /api/products/25
  

Here, 25 can identify the product.

Query Parameters

Query parameters are useful for filtering, searching, sorting, and pagination.

GET /api/products?category=laptop&page=2
  

REST API Pagination

Returning thousands or millions of records in a single API response can be inefficient.

APIs commonly provide pagination.

For example:

GET /api/products?page=1&limit=20
  

This could request a particular page containing a limited number of products.

The exact pagination design depends on the API.

REST API Filtering and Searching

Query parameters can also be used to filter resources.

GET /api/products?category=phones
GET /api/products?minPrice=10000&maxPrice=50000
GET /api/users?role=admin
  

A well-designed API should document supported query parameters and their expected values.

REST API Authentication

Many REST APIs require clients to authenticate before accessing protected resources.

Common approaches include:

  • API keys
  • Bearer tokens
  • OAuth-based flows
  • Session-based systems
  • Other token-based authentication mechanisms

A protected request could look like:

GET /api/profile

Authorization: Bearer YOUR_ACCESS_TOKEN
  

Authentication vs Authorization

These two concepts are related but different.

Authentication asks: "Who are you?"

Authorization asks: "What are you allowed to do?"

For example, a user might successfully authenticate but still receive a 403 Forbidden response when attempting an administrative operation without the required permission.

REST API Security Basics

REST APIs should be designed with security in mind from the beginning.

Use HTTPS

HTTPS protects API traffic in transit.

Validate Input

Never assume client-provided data is trustworthy.

Implement Authorization

Do not rely only on authentication. Verify that the authenticated identity has permission for each sensitive operation.

Protect Secrets

Do not hard-code passwords, API keys, private tokens, or database credentials in public source code.

Rate Limit Sensitive Endpoints

Rate limiting can help control abusive or excessive traffic and can be particularly important for authentication and resource-intensive endpoints.

Return Safe Errors

Errors should help legitimate clients understand the problem without revealing unnecessary internal details.

REST API Versioning

APIs can evolve over time.

When incompatible changes are introduced, existing applications may need protection from unexpected behavior.

A common versioning approach is:

/api/v1/users
/api/v2/users
  

Versioning strategies differ. Some APIs use URLs, while others use headers or other mechanisms.

What Are REST API Error Responses?

A useful API should provide structured error responses instead of returning confusing or inconsistent messages.

For example:

{
  "error": "validation_error",
  "message": "Email address is invalid",
  "field": "email"
}
  

The exact structure can vary, but consistency makes APIs easier to consume.

REST API Naming Best Practices

Resource-oriented naming can make an API easier to understand.

Prefer clear resource names:

/api/users
/api/products
/api/orders
  

rather than unnecessarily action-heavy URLs such as:

/api/getAllUsers
/api/createProduct
/api/deleteOrder
  

The HTTP method already communicates the intended operation in many REST designs.

REST API Example With Node.js and Express

Here is a simple learning example using Express.js.

const express = require("express");

const app = express();

app.use(express.json());

app.get("/api/users", (req, res) => {
  res.json([
    {
      id: 1,
      name: "Adarsh"
    },
    {
      id: 2,
      name: "Rahul"
    }
  ]);
});

app.post("/api/users", (req, res) => {
  const { name } = req.body;

  res.status(201).json({
    message: "User created",
    name
  });
});

app.listen(3000, () => {
  console.log("REST API running on port 3000");
});
  

This is only a learning example. A production API would also need appropriate validation, authentication, authorization, persistent storage, error handling, logging, security controls, and testing.

Calling a REST API From JavaScript

A frontend application can use the Fetch API to call a REST endpoint.

fetch("/api/users")
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
  

The frontend receives the JSON response and can use the returned data to update the interface.

Testing REST APIs

Before connecting an API to a frontend, developers can test it independently.

API testing tools can help you:

  • Send GET requests
  • Send POST requests
  • Modify request headers
  • Send JSON bodies
  • Test authentication
  • Inspect responses
  • Test error conditions
  • Save reusable requests

Postman, curl, and automated testing frameworks are commonly used for API testing.

Testing With curl

For example, a GET request can be sent from a terminal:

curl https://example.com/api/users
  

A POST request could look like:

curl -X POST https://example.com/api/users \
-H "Content-Type: application/json" \
-d '{"name":"Adarsh"}'
  

The exact command depends on the API and operating system.

REST API Architecture Example

                 Client
                   |
                   v
              REST API
                   |
              +----+----+
              |         |
              v         v
          Controller   Auth
              |
              v
        Business Logic
              |
              v
           Database
  

A larger production application may contain additional layers such as API gateways, caches, queues, background workers, external services, observability systems, and multiple backend services.

REST API vs SOAP API

REST SOAP
Architectural style Protocol
Commonly uses HTTP Can operate over multiple underlying transports
Often uses JSON, but other formats are possible Traditionally associated with XML messaging
Common in web and mobile APIs Often used in enterprise systems requiring SOAP features and contracts

REST API vs GraphQL

REST GraphQL
Usually exposes resource-oriented endpoints Often exposes a schema and query language
Uses HTTP methods heavily Clients commonly describe the fields they need
Often straightforward for standard CRUD APIs Can be useful when clients need flexible data selection

Common REST API Mistakes

  1. Using unclear or inconsistent endpoint names.
  2. Ignoring HTTP status codes.
  3. Returning inconsistent response structures.
  4. Skipping input validation.
  5. Checking authentication but not authorization.
  6. Exposing secrets in source code.
  7. Returning sensitive internal information in error messages.
  8. Ignoring rate limiting for sensitive endpoints.
  9. Changing API behavior without a migration strategy.
  10. Building an API without documentation and tests.

How to Build Your First REST API

Beginners can follow this practical sequence:

  1. Learn HTTP fundamentals.
  2. Understand request and response structure.
  3. Learn JSON.
  4. Learn GET, POST, PUT, PATCH, and DELETE.
  5. Understand endpoints and parameters.
  6. Learn CRUD.
  7. Build a small API with a backend framework.
  8. Connect a database.
  9. Add validation.
  10. Add authentication and authorization.
  11. Test the API.
  12. Document the endpoints.
  13. Deploy the application.

Beginner REST API Project Ideas

1. Todo API

Create, read, update, and delete tasks.

2. Student API

Manage student profiles, courses, and academic information.

3. Blog API

Manage posts, categories, comments, and authors.

4. Expense Tracker API

Create endpoints for recording and analyzing personal expenses.

5. Library Management API

Manage books, members, borrowing, and returns.

6. Authentication API

Build a learning project around registration, login, authentication, and role-based authorization.

Frequently Asked Questions

```

What is a REST API in simple words?

A REST API is a way for applications to communicate over HTTP using resource-oriented interfaces and standard HTTP methods.

What does REST stand for?

REST stands for Representational State Transfer.

Is REST a programming language?

No. REST is an architectural style for designing networked applications.

What is the difference between API and REST API?

API is a broad concept describing a software interface. REST API refers specifically to an API designed according to principles associated with REST.

What are the main REST API methods?

GET, POST, PUT, PATCH, and DELETE are commonly used in REST APIs.

What is CRUD in REST API?

CRUD means Create, Read, Update, and Delete. REST APIs commonly map these operations to HTTP methods.

Does every REST API use JSON?

No. REST does not require JSON. JSON is simply a very common representation format for modern web APIs.

What is a REST API endpoint?

An endpoint is a specific URL through which a client accesses a resource or operation exposed by an API.

Is REST API secure?

A REST API can be secure when it is correctly designed and implemented. Security requires appropriate authentication, authorization, transport protection, input validation, secret management, logging, and other controls.

Can beginners build REST APIs?

Yes. Beginners can start with a small CRUD API and gradually add databases, authentication, validation, testing, and deployment.

```

Final Thoughts

REST APIs provide a practical way for different software components to communicate over HTTP.

The most important concepts to understand are resources, endpoints, HTTP methods, requests, responses, JSON, status codes, CRUD, statelessness, authentication, authorization, and API security.

You do not need to memorize every REST concept before writing your first API. Build a small project, test each endpoint, inspect the requests and responses, and gradually add production-level features.

CodeWithAV REST API Learning Path:

HTTP → JSON → Resources → Endpoints → GET/POST → PUT/PATCH/DELETE → CRUD → Authentication → Authorization → Database → Testing → Documentation → Deployment.

Related Articles on CodeWithAV

What Is an API? Complete Beginner Guide

What Is JSON?

HTTP vs HTTPS Explained

HTTP Status Codes Every Developer Should Know

What Is Cloud Computing?

Explore More Web Development Guides

Disclosure: Some links on CodeWithAV may be affiliate links. If you purchase a product or service through an affiliate link, we may earn a commission at no additional cost to you. We aim to recommend products and services based on their relevance to our readers.

CodeWithAV — Learn, Discover & Build.

Adarsh verma

Adarsh verma

CodeWithAV publishes practical technology tutorials, study resources, programming guides, and cybersecurity learning content.

What Happens When You Type a URL? Step-by-Step Browser to Server Explained

What Happens When You Type a URL in Your Browser?

Every time you type a website address into your browser and press Enter, a series of networking, security and browser-processing steps happens in the background.

For example, suppose you enter:

https://example.com

You may see the webpage almost immediately, but the browser has to perform several operations before the content appears.

A simplified process looks like this:

Enter URL
   ↓
Browser Parses URL
   ↓
DNS Resolution
   ↓
Find Destination IP
   ↓
Network Connection
   ↓
TLS Security
   ↓
HTTP Request
   ↓
Server Processing
   ↓
HTTP Response
   ↓
Browser Receives Resources
   ↓
HTML / CSS / JavaScript Processing
   ↓
Rendering
   ↓
Webpage Appears

Let's examine each stage.

Step 1: You Enter a URL

A URL stands for Uniform Resource Locator.

It identifies a resource and provides information about how it can be accessed.

For example:

https://example.com/products?id=10

This URL contains several parts.

Breaking Down a URL

Part Example Purpose
Scheme https Specifies the protocol scheme
Host example.com Identifies the destination host
Path /products Identifies the requested resource or route
Query ?id=10 Carries additional request parameters

Step 2: The Browser Parses the URL

The browser determines what kind of resource you are requesting.

If you enter:

https://example.com

the browser recognizes:

  • The HTTPS scheme
  • The hostname example.com
  • The default path if none is explicitly specified

The browser then needs to determine where the hostname can be reached.

Step 3: Browser Checks Existing Information

Before contacting a DNS server, a browser and operating system may already have useful information cached.

Depending on the browser and environment, information can come from:

  • Browser caches
  • Operating-system DNS caches
  • Configured DNS resolvers
  • Existing connections
  • Other cached networking information

This can reduce the amount of work required for repeated visits.

What Is Caching?

Caching means storing information temporarily so that it can be reused later.

Caching can happen at multiple layers.

Browser Cache
      ↓
Operating System
      ↓
DNS Resolver Cache
      ↓
CDN Cache
      ↓
Origin Server

Not every request uses all these layers.

Step 4: DNS Lookup Begins

If the required DNS information is not already available, the system performs DNS resolution.

DNS stands for Domain Name System.

Its job includes helping map domain names to information used to locate internet services.

Instead of remembering something like:

203.0.113.20

you can type:

example.com

Step 5: DNS Resolver Searches for the Domain

Your device usually communicates with a DNS resolver configured by your network or chosen by you.

A simplified DNS resolution process can involve:

Your Computer
      ↓
DNS Resolver
      ↓
Root DNS Servers
      ↓
TLD DNS Servers
      ↓
Authoritative DNS Server
      ↓
DNS Answer

This is a simplified representation. DNS resolvers use caching, recursive queries and other mechanisms to make resolution efficient.

What Are Root DNS Servers?

Root DNS servers are part of the DNS hierarchy and direct resolvers toward the appropriate top-level-domain infrastructure.

For example, a domain ending in:

.com

belongs to the .com top-level domain.

What Are TLD DNS Servers?

TLD stands for Top-Level Domain.

Examples include:

  • .com
  • .org
  • .net
  • .in

TLD DNS infrastructure directs resolvers toward authoritative servers for specific domains.

What Is an Authoritative DNS Server?

An authoritative DNS server contains the DNS records for a domain or zone.

It can provide records such as:

  • A records
  • AAAA records
  • CNAME records
  • MX records
  • TXT records

What Is an A Record?

An A record maps a hostname to an IPv4 address.

A simplified example is:

example.com
     ↓
203.0.113.20

What Is an AAAA Record?

An AAAA record maps a hostname to an IPv6 address.

For example:

example.com
     ↓
2001:db8::20

Step 6: Browser Gets the Destination Address

After DNS resolution, the browser has the information it needs to attempt communication with the destination service.

It now has to establish an appropriate network connection.

Step 7: The Network Finds a Path

Your computer sends traffic through its local network.

A typical home setup may look like:

Laptop
  ↓
Wi-Fi / Ethernet
  ↓
Home Router
  ↓
ISP
  ↓
Internet
  ↓
Destination Network
  ↓
Server

Traffic may pass through several routers before reaching the destination.

What Is Routing?

Routing is the process of forwarding network traffic between networks using routing information.

A packet can travel through multiple network hops.

Step 8: A Transport Connection Is Established

For many HTTPS connections, TCP has traditionally been an important transport protocol.

With TCP, a connection begins through a process commonly called the TCP three-way handshake.

The simplified sequence is:

Client → SYN → Server

Client ← SYN-ACK ← Server

Client → ACK → Server

This establishes the TCP connection.

Modern web traffic can also use other transport protocols and HTTP versions, such as HTTP/3 over QUIC, so the exact connection process is not always a TCP handshake.

What Is a Port?

A port identifies a logical endpoint associated with a transport-layer service.

HTTPS commonly uses:

TCP 443

HTTP commonly uses:

TCP 80

Services can be configured differently, but these are the standard well-known associations.

Step 9: TLS Handshake for HTTPS

Because our URL begins with https://, the browser establishes a secure TLS session.

At a high level, TLS allows the browser and server to establish cryptographic protections for the connection.

A simplified concept is:

Browser
   ↕
TLS Handshake
   ↕
Server

       ↓

Secure Session

What Does TLS Provide?

TLS is designed to provide properties such as:

  • Confidentiality
  • Integrity
  • Authentication of the server using certificates

What Is a TLS Certificate?

A TLS certificate contains information used to establish trust in the identity of a server for a domain.

The browser checks the certificate chain and other certificate properties according to its security rules.

Step 10: Browser Sends an HTTP Request

Once the appropriate connection is ready, the browser sends an HTTP request.

A simplified request might be:

GET / HTTP/1.1
Host: example.com

Actual browser requests contain many additional headers depending on the browser, page and connection.

What Is an HTTP Request?

An HTTP request contains:

  • Method
  • Target
  • Headers
  • Optional body

Common HTTP Methods

Method Typical Purpose
GET Retrieve a resource
POST Submit data or request processing
PUT Replace a resource
PATCH Partially update a resource
DELETE Request removal of a resource

What Are HTTP Headers?

HTTP headers carry metadata about the request or response.

Examples include:

  • Host
  • User-Agent
  • Accept
  • Accept-Encoding
  • Cookie
  • Authorization

Different requests contain different headers.

Step 11: Request Reaches the Web Infrastructure

The HTTP request may first reach infrastructure such as:

  • CDN
  • Reverse proxy
  • Load balancer
  • Web server
  • Application server

A large website can use several of these components.

Example Infrastructure

Browser
   ↓
CDN
   ↓
Reverse Proxy
   ↓
Load Balancer
   ↓
Application Server
   ↓
Database

Step 12: Server Determines What to Do

Suppose you request:

GET /products/101

The application may:

  1. Identify the requested route.
  2. Validate parameters.
  3. Check authentication if required.
  4. Run business logic.
  5. Query a database.
  6. Prepare the response.

Static Website Example

If the website is static, the server may simply return an existing file.

Request
  ↓
Web Server
  ↓
index.html
  ↓
Response

Dynamic Website Example

A dynamic application may perform additional processing:

Request
  ↓
Backend
  ↓
Database
  ↓
Business Logic
  ↓
HTML / JSON
  ↓
Response

Step 13: Database Query May Happen

Suppose the application needs product information.

The backend might execute a database query such as:

SELECT *
FROM products
WHERE id = 101;

The database returns the matching information, and the backend uses it to construct the response.

Step 14: Server Creates the Response

The server now sends an HTTP response back to the browser.

A simplified response might look like:

HTTP/1.1 200 OK
Content-Type: text/html

The response contains:

  • Status code
  • Headers
  • Response body

What Is an HTTP Status Code?

An HTTP status code indicates the result of an HTTP request.

Code Meaning
200 Success
301 Permanent redirect
302 Temporary redirect
400 Bad request
401 Authentication required or failed
403 Forbidden
404 Not found
500 Internal server error

Step 15: Browser Receives the Response

The browser receives the HTTP response and begins processing its contents.

If the content type is HTML, the browser parses the HTML document.

What Is HTML?

HTML stands for HyperText Markup Language.

It defines the structure of a webpage.

Example:

<h1>Welcome to CodeWithAV</h1>

<p>
Learn programming and technology.
</p>

Step 16: Browser Finds More Resources

The HTML document may reference:

  • CSS files
  • JavaScript files
  • Images
  • Fonts
  • Video
  • Other resources

The browser may then make additional requests.

For example:

GET /style.css
GET /app.js
GET /logo.png
GET /font.woff2

Why Does One Website Make So Many Requests?

A modern webpage is usually made from many individual resources.

Therefore, loading one page can involve many network requests.

Step 17: CSS Is Processed

CSS controls how webpage elements are presented.

For example:

h1 {
    font-size: 32px;
}

.card {
    padding: 20px;
}

The browser combines HTML structure and CSS rules to determine how elements should appear.

Step 18: JavaScript Runs

JavaScript can add behavior and interactivity to the webpage.

For example:

document
    .querySelector("#button")
    .addEventListener("click", () => {
        alert("Hello!");
    });

JavaScript can also make additional network requests.

Step 19: Browser Builds the DOM

The browser creates a DOM (Document Object Model) representation of the HTML.

A simplified structure could look like:

HTML
 |
 +-- HEAD
 |
 +-- BODY
      |
      +-- H1
      |
      +-- P
      |
      +-- BUTTON

JavaScript can interact with this structure.

Step 20: Browser Calculates Layout

The browser determines where elements should appear on the screen.

It considers:

  • Element dimensions
  • Margins
  • Padding
  • Fonts
  • Positioning
  • Responsive rules

Step 21: Browser Paints the Page

The browser converts the calculated layout into visual pixels.

It may then composite different layers before presenting the final result.

A simplified rendering flow is:

HTML
 ↓
DOM
 ↓
CSS
 ↓
Style Calculation
 ↓
Layout
 ↓
Paint
 ↓
Compositing
 ↓
Screen

Step 22: Page Becomes Interactive

Once the relevant resources and scripts have loaded and executed, the user can interact with the page.

For example:

  • Click buttons
  • Submit forms
  • Open menus
  • Scroll
  • Search
  • Load additional content

What Happens When You Click a Button?

Modern websites often respond without a complete page reload.

A simplified process could be:

Click
 ↓
JavaScript Event
 ↓
Fetch / API Request
 ↓
Backend
 ↓
Database
 ↓
JSON Response
 ↓
JavaScript
 ↓
Update UI

What Is AJAX?

AJAX is a historical term for techniques that allow web pages to communicate with servers asynchronously and update parts of a page without requiring a traditional full-page navigation.

Modern applications commonly use the Fetch API and other browser APIs for such communication.

What Is JSON?

JSON stands for JavaScript Object Notation.

It is commonly used for exchanging structured data.

Example:

{
    "name": "Laptop",
    "price": 55000
}

What If the URL Does Not Exist?

If the requested resource does not exist, the server may return:

404 Not Found

The browser may display a custom error page.

What If the Server Has a Problem?

If the server experiences an internal error, it may return:

500 Internal Server Error

The exact status depends on the nature of the failure.

What If DNS Fails?

If the domain cannot be resolved, the browser cannot determine the destination using normal DNS-based resolution.

You may see a browser error indicating a DNS or name-resolution problem.

What If the TLS Certificate Is Invalid?

Modern browsers can warn or block access when a TLS certificate is invalid, expired, incorrectly configured or otherwise fails security checks.

This protects users against certain types of connection problems and attacks.

What If the Server Is Slow?

The page may take longer to load.

Possible causes include:

  • High network latency
  • Server processing time
  • Database queries
  • Large files
  • Slow external services
  • Network congestion

What Is Time to First Byte?

Time to First Byte (TTFB) measures the elapsed time from a request until the first byte of the response is received.

It can be affected by:

  • DNS time
  • Connection setup
  • TLS negotiation
  • Server processing
  • Network latency

TTFB is useful, but it is only one part of overall web performance.

What Is Browser Caching?

Browsers can store copies of cacheable resources locally.

For example:

First Visit
   ↓
Download CSS / JS / Images
   ↓
Store Cache

Later Visit
   ↓
Reuse Suitable Cached Resources

This can reduce network requests and improve subsequent page loads.

What Is CDN Caching?

A CDN can cache suitable resources at edge locations closer to users.

For example:

User
 ↓
CDN Edge
 ↓
Cached Image

or

User
 ↓
CDN Edge
 ↓
Origin Server

Whether something can be cached depends on configuration, HTTP caching rules and the type of resource.

What Is a Redirect?

A server can tell the browser that a resource has moved to another location.

For example:

Old URL
  ↓
301 Redirect
  ↓
New URL

The browser then requests the new destination.

Can One URL Cause Multiple Redirects?

Yes.

A poorly configured website can create redirect chains.

For example:

URL A
 ↓
URL B
 ↓
URL C
 ↓
URL D

Multiple unnecessary redirects can increase latency.

What Happens With Cookies?

A website can use cookies to maintain certain client-side state.

For example, an authentication session can involve:

Login Request
    ↓
Server Creates Session
    ↓
Cookie Sent
    ↓
Browser Stores Cookie
    ↓
Future Requests Include Cookie

Cookie behavior is controlled by attributes and browser security policies.

What Is Same-Origin Policy?

The same-origin policy is a fundamental browser security mechanism that restricts how scripts from one origin can interact with resources from another origin.

It helps limit unauthorized access between unrelated websites.

What Is CORS?

CORS stands for Cross-Origin Resource Sharing.

It provides a controlled mechanism through which a server can allow certain cross-origin browser requests.

For example:

Frontend
https://app.example.com

        ↓

API
https://api.example.com

        ↓

CORS Policy

Whether the request is allowed depends on the server's CORS configuration and the browser's rules.

What Happens if JavaScript Calls an API?

A page can make additional requests after loading.

For example:

fetch("/api/users")
    .then(response => response.json())
    .then(data => {
        console.log(data);
    });

This creates another HTTP request.

Complete Example: Opening an Online Store

Suppose you open:

https://store.example.com/products/101

The simplified sequence may be:

  1. Browser parses the URL.
  2. Browser checks available cached information.
  3. DNS resolution determines the destination.
  4. Network traffic travels toward the destination.
  5. A suitable transport connection is established.
  6. TLS secures the HTTPS connection.
  7. Browser sends an HTTP request.
  8. CDN or reverse proxy may receive it.
  9. Backend application processes the request.
  10. Backend may query a database.
  11. Server generates HTML.
  12. HTTP response returns to the browser.
  13. Browser parses HTML.
  14. Browser requests CSS, JavaScript and images.
  15. JavaScript runs.
  16. Browser calculates layout.
  17. Browser paints the page.
  18. User sees the product page.

The Entire Process in One Diagram

User Types URL
       ↓
Browser Parses URL
       ↓
Cache Check
       ↓
DNS Resolution
       ↓
Destination IP
       ↓
Network Routing
       ↓
Transport Connection
       ↓
TLS Handshake
       ↓
HTTP Request
       ↓
CDN / Proxy / Server
       ↓
Backend Processing
       ↓
Database / APIs
       ↓
HTTP Response
       ↓
HTML Parsing
       ↓
CSS + JavaScript + Images
       ↓
DOM + Layout
       ↓
Paint + Composite
       ↓
Interactive Webpage

Why Understanding This Process Matters

If you want to become a web developer, networking engineer or cybersecurity professional, understanding what happens after you enter a URL is extremely useful.

It connects many concepts:

  • DNS
  • IP addresses
  • Routing
  • TCP
  • QUIC
  • TLS
  • HTTP
  • Servers
  • Databases
  • HTML
  • CSS
  • JavaScript

How Developers Can Observe This Process

You do not need to imagine everything happening in the background. Your browser can show you many of these details.

Open Developer Tools → Network.

You can inspect:

  • Request URLs
  • HTTP methods
  • Status codes
  • Response headers
  • Request headers
  • Timing information
  • Transferred data
  • Cached resources

Try This Practical Exercise

Open any website and inspect its Network panel.

Look for:

HTML
CSS
JavaScript
Images
Fonts
API Requests
Redirects
Status Codes

Then refresh the page and compare the requests.

You may notice that some resources are loaded differently because of caching or connection reuse.

Useful Commands for Beginners

You can also learn networking from the command line.

Check DNS

Windows:

nslookup example.com

Linux/macOS systems may support:

dig example.com

Test Network Reachability

ping example.com

Remember that a host can be reachable even when it does not respond to ICMP echo requests.

Inspect the Network Path

Windows:

tracert example.com

Linux/macOS commonly use:

traceroute example.com

Common Errors You May See

Problem Possible Area
DNS error Domain resolution
Connection refused Destination service or firewall
Timeout Network, routing or server issue
404 Requested resource not found
403 Access forbidden
500 Server-side error
TLS warning Certificate or TLS configuration problem

Final Cheat Sheet

Stage Main Technology / Concept
URL Parsing Browser / URL syntax
Name Resolution DNS
Addressing IP
Routing Routers / IP routing
Transport TCP, UDP, QUIC
Security TLS
Web Communication HTTP / HTTPS
Application Backend / APIs / Database
Page Processing HTML / CSS / JavaScript
Display Browser rendering

Final Thoughts

Typing a URL looks like a simple action, but it starts a chain of operations across browsers, DNS systems, networks, servers and rendering engines.

The simplified sequence is:

URL
 ↓
DNS
 ↓
IP
 ↓
Network
 ↓
Transport
 ↓
TLS
 ↓
HTTP
 ↓
Server
 ↓
Response
 ↓
Browser
 ↓
Rendering

Once you understand this process, many web-development and networking concepts become easier to understand because you can see how they connect together.

For beginners, one of the best exercises is to open your browser's Network tab and inspect what actually happens when you load a page. Look at the request URLs, status codes, timing, response headers and downloaded resources.

What appears to be “opening a website” is actually a carefully coordinated conversation between many software and network components.


Frequently Asked Questions

What happens first when you type a URL?

The browser parses the URL and determines what scheme and host are being requested. It may also use cached information before performing additional network operations.

What is the first network service usually involved?

For a normal domain-based web request, DNS resolution may be needed to obtain information used to locate the destination.

Why does the browser need DNS?

DNS allows applications to use human-readable domain names while networking systems use IP-based addressing to communicate across networks.

Does every website use TCP?

No. Traditional HTTP/1.1 and HTTP/2 connections commonly use TCP, while HTTP/3 uses QUIC, which operates over UDP.

Why does HTTPS use TLS?

TLS provides cryptographic protections such as confidentiality and integrity and allows the browser to authenticate the server through certificates.

What is the difference between HTTP and HTTPS?

HTTPS is HTTP communicated over TLS, providing security protections for the connection.

What happens after the browser sends an HTTP request?

The request may pass through a CDN, reverse proxy, load balancer or web server before reaching application logic. The backend may then access databases or other services and generate the response.

Why does a webpage make many requests?

A webpage can require HTML, CSS, JavaScript, images, fonts and API data, so the browser may request many separate resources.

What happens when a website returns 404?

A 404 status generally means that the requested resource was not found at the requested location.

What happens when DNS fails?

The browser may be unable to determine the destination address and can show a DNS or name-resolution error.

What is browser caching?

Browser caching stores suitable resources locally so they can sometimes be reused on later requests without downloading them again.

What is a CDN?

A Content Delivery Network distributes suitable content through geographically distributed infrastructure and can serve cached resources closer to users.

What should I learn after understanding URL processing?

Continue with DNS, IP addressing, TCP/UDP/QUIC, HTTP/HTTPS, web servers, APIs, databases, browser rendering and web security.

Useful Resources

MDN HTTP Documentation
MDN Web Development Learning
ICANN
Internet Engineering Task Force
Cloudflare Learning – DNS

Related Articles on CodeWithAV

What Is the Internet and How Does It Work?
How a Website Works From Browser to Server
What Is DNS?
How DNS Resolution Works
HTTP vs HTTPS Explained
What Is an API? Complete Beginner Guide

Disclosure: Some links on CodeWithAV may be affiliate links. If you purchase a product or service through an affiliate link, we may earn a commission at no additional cost to you. We aim to recommend products and services based on their relevance to our readers.
Adarsh verma

Adarsh verma

CodeWithAV publishes practical technology tutorials, study resources, programming guides, and cybersecurity learning content.