<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: DevOps Drops</title>
    <description>The latest articles on DEV Community by DevOps Drops (@devopsdrops).</description>
    <link>https://dev.to/devopsdrops</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4285912%2F3dd60c3f-780e-475b-aeb4-5815d8c8a09b.png</url>
      <title>DEV Community: DevOps Drops</title>
      <link>https://dev.to/devopsdrops</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devopsdrops"/>
    <language>en</language>
    <item>
      <title>DNS Records Explained: A, AAAA, CNAME, MX, TXT and More</title>
      <dc:creator>DevOps Drops</dc:creator>
      <pubDate>Sun, 06 Dec 2026 08:05:03 +0000</pubDate>
      <link>https://dev.to/devopsdrops/dns-records-explained-a-aaaa-cname-mx-txt-and-more-4moe</link>
      <guid>https://dev.to/devopsdrops/dns-records-explained-a-aaaa-cname-mx-txt-and-more-4moe</guid>
      <description>&lt;h2&gt;
  
  
  What Are DNS Records?
&lt;/h2&gt;

&lt;p&gt;DNS records are instructions stored on DNS servers that tell the internet how a domain should behave. They connect human-readable domain names like &lt;strong&gt;example.com&lt;/strong&gt; to the services and servers that power them.&lt;/p&gt;

&lt;p&gt;When someone visits a website, sends an email, or verifies ownership of a domain, DNS records provide the information needed to complete that request.&lt;/p&gt;

&lt;p&gt;A DNS record is made up of several important parts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Type    Name              Value              TTL

A       example.com       192.0.2.10         3600
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Type&lt;/strong&gt; - The kind of DNS record.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Name&lt;/strong&gt; - The domain or subdomain the record applies to.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value&lt;/strong&gt; - The destination or information stored in the record.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TTL&lt;/strong&gt; - How long DNS resolvers should cache the result.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Are DNS Records Important?
&lt;/h2&gt;

&lt;p&gt;DNS records are responsible for much more than simply pointing a domain to a website. They are used for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Directing website traffic to servers&lt;/li&gt;
&lt;li&gt;Routing email to mail providers&lt;/li&gt;
&lt;li&gt;Verifying domain ownership&lt;/li&gt;
&lt;li&gt;Configuring security features&lt;/li&gt;
&lt;li&gt;Connecting services and infrastructure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For DevOps engineers, understanding DNS records is essential when deploying applications, configuring cloud services, and troubleshooting connectivity problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Records
&lt;/h2&gt;

&lt;p&gt;An A record maps a domain name to an IPv4 address.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;example.com → 192.0.2.10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a user visits &lt;strong&gt;example.com&lt;/strong&gt;, the DNS resolver can use this record to find the server hosting the website.&lt;/p&gt;

&lt;p&gt;A typical website might have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Type: A
Name: example.com
Value: 203.0.113.25
TTL: 3600
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  AAAA Records
&lt;/h2&gt;

&lt;p&gt;AAAA records perform the same role as A records but point to IPv6 addresses instead of IPv4.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;example.com → 2001:db8::10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As IPv6 adoption increases, AAAA records are becoming more common alongside traditional A records.&lt;/p&gt;

&lt;h2&gt;
  
  
  CNAME Records
&lt;/h2&gt;

&lt;p&gt;A CNAME (Canonical Name) record creates an alias from one domain name to another.&lt;/p&gt;

&lt;p&gt;Instead of pointing directly to an IP address, it points to another hostname.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;www.example.com → example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A common use case is pointing a subdomain towards a managed service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;blog.example.com → hosting-provider.example.net
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CNAME records are useful because the destination can change without updating every domain that references it.&lt;/p&gt;

&lt;h2&gt;
  
  
  MX Records
&lt;/h2&gt;

&lt;p&gt;MX (Mail Exchange) records tell email servers where to deliver messages for a domain.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;example.com → mail.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A domain can have multiple MX records with different priorities.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Priority   Server

10         mail1.example.com
20         mail2.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the highest priority mail server is unavailable, another server can accept incoming email.&lt;/p&gt;

&lt;h2&gt;
  
  
  TXT Records
&lt;/h2&gt;

&lt;p&gt;TXT records store arbitrary text information associated with a domain.&lt;/p&gt;

&lt;p&gt;They are commonly used for verification and security purposes.&lt;/p&gt;

&lt;p&gt;Common uses include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Email authentication&lt;/li&gt;
&lt;li&gt;Domain ownership verification&lt;/li&gt;
&lt;li&gt;Service configuration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example SPF record:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;v=spf1 include:_spf.google.com ~all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Services such as Google Workspace, Microsoft 365, and GitHub often require TXT records to verify that you control a domain.&lt;/p&gt;

&lt;h2&gt;
  
  
  NS Records
&lt;/h2&gt;

&lt;p&gt;NS (Name Server) records define which DNS servers are responsible for managing a domain.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;example.com

ns1.example-dns.com
ns2.example-dns.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a DNS resolver needs information about a domain, it follows the NS records to find the authoritative DNS servers.&lt;/p&gt;

&lt;h2&gt;
  
  
  SOA Records
&lt;/h2&gt;

&lt;p&gt;The SOA (Start of Authority) record contains important information about a DNS zone.&lt;/p&gt;

&lt;p&gt;It includes details such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The primary authoritative DNS server&lt;/li&gt;
&lt;li&gt;The domain administrator&lt;/li&gt;
&lt;li&gt;Zone version information&lt;/li&gt;
&lt;li&gt;DNS refresh settings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every DNS zone has an SOA record.&lt;/p&gt;

&lt;h2&gt;
  
  
  SRV Records
&lt;/h2&gt;

&lt;p&gt;SRV records define the location of specific services.&lt;/p&gt;

&lt;p&gt;They are commonly used for applications that need to discover services automatically.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;_service._protocol.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Voice and video applications&lt;/li&gt;
&lt;li&gt;Messaging systems&lt;/li&gt;
&lt;li&gt;Enterprise services&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How To Check DNS Records
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;dig&lt;/code&gt; command is one of the most useful tools for inspecting DNS records.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can request specific record types:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig example.com A

dig example.com MX

dig example.com TXT

dig example.com NS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output shows the DNS response returned by the authoritative servers.&lt;/p&gt;

&lt;h2&gt;
  
  
  DNS Records and TTL
&lt;/h2&gt;

&lt;p&gt;Every DNS record has a TTL (Time To Live) value that controls how long DNS resolvers cache the response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TTL: 3600
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A TTL of 3600 means the record can be cached for one hour before checking for an updated value.&lt;/p&gt;

&lt;p&gt;Lower TTL values are useful when making changes because updates propagate faster. Higher TTL values reduce DNS query traffic and improve efficiency.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common DNS Record Problems
&lt;/h2&gt;

&lt;p&gt;Incorrect DNS records are a common cause of website and infrastructure issues.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Wrong A record:&lt;/strong&gt; Traffic is sent to the wrong server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Missing MX record:&lt;/strong&gt; Email delivery fails.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Incorrect CNAME:&lt;/strong&gt; Services cannot be reached.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Missing TXT record:&lt;/strong&gt; Verification checks fail.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tools like &lt;code&gt;dig&lt;/code&gt;, &lt;code&gt;nslookup&lt;/code&gt;, and online DNS checkers can help identify these issues.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why DNS Records Matter For DevOps
&lt;/h2&gt;

&lt;p&gt;DNS records are a fundamental part of modern infrastructure.&lt;/p&gt;

&lt;p&gt;They are involved in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deploying applications behind domains&lt;/li&gt;
&lt;li&gt;Configuring load balancers&lt;/li&gt;
&lt;li&gt;Setting up SSL certificates&lt;/li&gt;
&lt;li&gt;Managing cloud services&lt;/li&gt;
&lt;li&gt;Connecting microservices&lt;/li&gt;
&lt;li&gt;Routing traffic between environments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A good understanding of DNS records makes troubleshooting production systems much easier. Many issues that appear to be application failures are actually DNS configuration problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;DNS records are the foundation of how the internet connects services together. While there are many different record types, each one has a specific purpose.&lt;/p&gt;

&lt;p&gt;Understanding A, AAAA, CNAME, MX, TXT, and other DNS records gives developers and DevOps engineers the knowledge needed to build, deploy, and troubleshoot reliable infrastructure.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://devopsdrops.uk/articles/dns-records-explained?utm_source=devto&amp;amp;utm_medium=social&amp;amp;utm_campaign=distribution" rel="noopener noreferrer"&gt;The DevOps Drop&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>dns</category>
      <category>networking</category>
      <category>infrastructure</category>
      <category>devops</category>
    </item>
    <item>
      <title>HTTP 301 vs 302 vs 307: What's the Difference?</title>
      <dc:creator>DevOps Drops</dc:creator>
      <pubDate>Sun, 06 Dec 2026 07:35:06 +0000</pubDate>
      <link>https://dev.to/devopsdrops/http-301-vs-302-vs-307-whats-the-difference-553f</link>
      <guid>https://dev.to/devopsdrops/http-301-vs-302-vs-307-whats-the-difference-553f</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;HTTP redirects are a fundamental part of how websites and web applications handle changes to URLs. Whether you're moving a page to a new location, redirecting visitors to a secure version of your website, or temporarily routing traffic elsewhere, HTTP provides several status codes to manage these situations.&lt;/p&gt;

&lt;p&gt;Three of the most commonly used redirect status codes are &lt;strong&gt;301 Moved Permanently&lt;/strong&gt;, &lt;strong&gt;302 Found&lt;/strong&gt;, and &lt;strong&gt;307 Temporary Redirect&lt;/strong&gt;. Although they all instruct a client to access another URL, there are important differences in how they behave.&lt;/p&gt;

&lt;p&gt;Choosing the wrong redirect can cause unexpected behaviour, particularly when working with POST requests, APIs, and applications that rely on specific HTTP methods.&lt;/p&gt;

&lt;p&gt;In this guide, we'll explain the differences between HTTP 301, 302 and 307 redirects, when to use each one, and how to configure and test them using Nginx and curl.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is an HTTP Redirect?
&lt;/h2&gt;

&lt;p&gt;An HTTP redirect is a response from a web server telling a client that a requested resource is available at another URL.&lt;/p&gt;

&lt;p&gt;Rather than returning the requested content directly, the server responds with a 3xx status code and includes a &lt;code&gt;Location&lt;/code&gt; header containing the destination URL.&lt;/p&gt;

&lt;p&gt;For example, a server might return the following response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt; &lt;span class="mi"&gt;301&lt;/span&gt; &lt;span class="nc"&gt;Moved&lt;/span&gt; &lt;span class="nc"&gt;Permanently&lt;/span&gt;
&lt;span class="nc"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//example.com/new-page&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser or HTTP client can then follow the redirect and make another request to the new URL.&lt;/p&gt;

&lt;p&gt;Redirects are commonly used when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A website moves to a new domain.&lt;/li&gt;
&lt;li&gt;A page URL changes permanently.&lt;/li&gt;
&lt;li&gt;HTTP traffic needs to be redirected to HTTPS.&lt;/li&gt;
&lt;li&gt;A resource is temporarily unavailable.&lt;/li&gt;
&lt;li&gt;An application needs to redirect requests to another endpoint.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  HTTP 301 vs 302 vs 307: What's the Difference?
&lt;/h2&gt;

&lt;p&gt;The main differences between these status codes are whether the redirect is permanent or temporary, and whether the original HTTP request method must be preserved.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Status Code&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;Redirect Type&lt;/th&gt;
&lt;th&gt;Method Preservation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;301&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Moved Permanently&lt;/td&gt;
&lt;td&gt;Permanent&lt;/td&gt;
&lt;td&gt;Not guaranteed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;302&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Found&lt;/td&gt;
&lt;td&gt;Temporary&lt;/td&gt;
&lt;td&gt;Not guaranteed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;307&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Temporary Redirect&lt;/td&gt;
&lt;td&gt;Temporary&lt;/td&gt;
&lt;td&gt;Preserved&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;308&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Permanent Redirect&lt;/td&gt;
&lt;td&gt;Permanent&lt;/td&gt;
&lt;td&gt;Preserved&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Let's look at each status code in more detail.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. HTTP 301 – Moved Permanently
&lt;/h2&gt;

&lt;p&gt;An HTTP 301 response tells the client that a resource has permanently moved to a different URL.&lt;/p&gt;

&lt;p&gt;It's generally used when the original URL is no longer intended to be the primary location of the resource and future requests should use the new destination.&lt;/p&gt;

&lt;p&gt;For example, imagine moving a website from HTTP to HTTPS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A 301 redirect tells browsers and search engines that the HTTPS version is the permanent destination.&lt;/p&gt;

&lt;h3&gt;
  
  
  When Should You Use a 301 Redirect?
&lt;/h3&gt;

&lt;p&gt;Common examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Moving a website from HTTP to HTTPS.&lt;/li&gt;
&lt;li&gt;Changing a page URL permanently.&lt;/li&gt;
&lt;li&gt;Moving a website to a new domain.&lt;/li&gt;
&lt;li&gt;Removing duplicate URL variations.&lt;/li&gt;
&lt;li&gt;Restructuring website URLs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Configuring a 301 Redirect in Nginx
&lt;/h3&gt;

&lt;p&gt;You can use the Nginx &lt;code&gt;return&lt;/code&gt; directive to create a permanent redirect.&lt;/p&gt;

&lt;p&gt;For example, to redirect HTTP traffic to HTTPS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="n"&gt;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;listen&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;server_name&lt;/span&gt; &lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt; &lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;301&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//example.com$request_uri;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells Nginx to return a 301 response and redirect visitors to the HTTPS version of the requested URL.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;$request_uri&lt;/code&gt; variable preserves the original request path and query string.&lt;/p&gt;

&lt;p&gt;For example, a request to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://example.com/about?ref=homepage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Would be redirected to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://example.com/about?ref=homepage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. HTTP 302 – Found
&lt;/h2&gt;

&lt;p&gt;An HTTP 302 response indicates that a resource is temporarily available at another URL.&lt;/p&gt;

&lt;p&gt;Unlike a 301 redirect, the original URL is still considered the intended location. Clients should continue using the original URL for future requests.&lt;/p&gt;

&lt;p&gt;For example, imagine temporarily redirecting visitors from your homepage to a maintenance page. You don't want browsers or search engines treating the maintenance page as a permanent replacement.&lt;/p&gt;

&lt;p&gt;A 302 redirect is appropriate for this situation.&lt;/p&gt;

&lt;h3&gt;
  
  
  When Should You Use a 302 Redirect?
&lt;/h3&gt;

&lt;p&gt;Common examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Temporarily redirecting visitors during maintenance.&lt;/li&gt;
&lt;li&gt;Sending users to a temporary campaign page.&lt;/li&gt;
&lt;li&gt;Redirecting users based on temporary application conditions.&lt;/li&gt;
&lt;li&gt;Temporarily directing traffic to another endpoint.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Configuring a 302 Redirect in Nginx
&lt;/h3&gt;

&lt;p&gt;You can configure a temporary redirect using the Nginx &lt;code&gt;return&lt;/code&gt; directive:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="n"&gt;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;listen&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;server_name&lt;/span&gt; &lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;302&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//example.com/temporary-page;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a visitor requests &lt;code&gt;/old-page&lt;/code&gt;, Nginx responds with a 302 status code and directs the visitor to &lt;code&gt;/temporary-page&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Once the temporary redirect is no longer required, you can remove or update the configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. HTTP 307 – Temporary Redirect
&lt;/h2&gt;

&lt;p&gt;An HTTP 307 response is also a temporary redirect, but it has an important difference compared with a 302.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A 307 redirect requires the client to preserve the original HTTP request method when following the redirect.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This means that if a client sends a POST request to a URL and receives a 307 response, it must use POST when making the redirected request.&lt;/p&gt;

&lt;p&gt;This is particularly important when working with APIs, forms, and endpoints that process submitted data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Does Preserving the Request Method Matter?
&lt;/h3&gt;

&lt;p&gt;Imagine an application receives the following request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;login&lt;/span&gt; &lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt;
&lt;span class="nc"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;
&lt;span class="nc"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"username"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user123"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the server responds with a 302 redirect, a client may change the subsequent request method from POST to GET. This behaviour is permitted for historical compatibility reasons.&lt;/p&gt;

&lt;p&gt;However, a 307 redirect explicitly tells the client not to change the request method when following the redirect.&lt;/p&gt;

&lt;p&gt;The redirected request should therefore remain a POST request, with its request body preserved.&lt;/p&gt;

&lt;h3&gt;
  
  
  When Should You Use a 307 Redirect?
&lt;/h3&gt;

&lt;p&gt;Common examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Temporarily redirecting API requests.&lt;/li&gt;
&lt;li&gt;Moving an endpoint without changing its request method.&lt;/li&gt;
&lt;li&gt;Redirecting POST requests while preserving their behaviour.&lt;/li&gt;
&lt;li&gt;Temporarily routing application traffic to another service.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Configuring a 307 Redirect in Nginx
&lt;/h3&gt;

&lt;p&gt;Nginx can return a 307 response using the &lt;code&gt;return&lt;/code&gt; directive:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="n"&gt;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;listen&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;server_name&lt;/span&gt; &lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;307&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//api.example.com$request_uri;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells clients that the requested API resource is temporarily available at another URL.&lt;/p&gt;

&lt;p&gt;When following the redirect, clients must preserve the original request method.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is HTTP 308 – Permanent Redirect?
&lt;/h2&gt;

&lt;p&gt;Although this guide focuses on 301, 302 and 307 redirects, it's also worth understanding HTTP 308.&lt;/p&gt;

&lt;p&gt;A 308 response is the permanent equivalent of a 307 redirect. It tells clients that a resource has permanently moved while requiring them to preserve the original request method.&lt;/p&gt;

&lt;p&gt;This makes it useful when permanently moving API endpoints that accept POST, PUT, or other non-GET requests.&lt;/p&gt;

&lt;p&gt;Here's how the four redirect types compare:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Status Code&lt;/th&gt;
&lt;th&gt;Redirect Type&lt;/th&gt;
&lt;th&gt;Preserves Request Method?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;301&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Permanent&lt;/td&gt;
&lt;td&gt;Not guaranteed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;302&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Temporary&lt;/td&gt;
&lt;td&gt;Not guaranteed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;307&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Temporary&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;308&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Permanent&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  How to Test HTTP Redirects Using curl
&lt;/h2&gt;

&lt;p&gt;You don't need a browser to inspect HTTP redirects. The &lt;code&gt;curl&lt;/code&gt; command-line utility makes it easy to see which status code a server returns.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Check the Response Headers
&lt;/h3&gt;

&lt;p&gt;Use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -I http://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-I&lt;/code&gt; option requests the response headers without downloading the response body.&lt;/p&gt;

&lt;p&gt;You might see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt; &lt;span class="mi"&gt;301&lt;/span&gt; &lt;span class="nc"&gt;Moved&lt;/span&gt; &lt;span class="nc"&gt;Permanently&lt;/span&gt;
&lt;span class="nc"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//example.com/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This confirms that the server is returning a 301 redirect.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Follow a Redirect
&lt;/h3&gt;

&lt;p&gt;To follow redirects automatically, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -L http://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-L&lt;/code&gt; option tells curl to follow HTTP redirects.&lt;/p&gt;

&lt;p&gt;You can also use verbose output to inspect the individual requests and responses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -v -L http://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is useful when troubleshooting unexpected redirect behaviour or identifying a redirect loop.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Test a POST Request
&lt;/h3&gt;

&lt;p&gt;You can test how a server handles a POST request using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -v -L \
    -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
    -d &lt;span class="s1"&gt;'{"test":true}'&lt;/span&gt; \
    https://example.com/api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The verbose output lets you inspect the redirect responses and subsequent requests.&lt;/p&gt;

&lt;p&gt;This is particularly useful when testing API redirects where preserving the original request method is important.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes When Configuring Redirects
&lt;/h2&gt;

&lt;p&gt;Even though redirects are relatively straightforward, there are a few mistakes worth avoiding.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using a Permanent Redirect for a Temporary Change
&lt;/h3&gt;

&lt;p&gt;If a redirect is only intended to last a few hours or days, using a 301 may cause unwanted caching and make it harder to reverse the change.&lt;/p&gt;

&lt;p&gt;Use a temporary redirect when the original URL is expected to become available again.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using a 302 When the Request Method Must Be Preserved
&lt;/h3&gt;

&lt;p&gt;If your application handles POST requests, don't assume a 302 redirect will preserve the original request method.&lt;/p&gt;

&lt;p&gt;Use a 307 for temporary redirects where preserving the request method is important.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Redirect Loops
&lt;/h3&gt;

&lt;p&gt;A redirect loop occurs when two or more URLs continually redirect to each other.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/page-a -&amp;gt; /page-b
/page-b -&amp;gt; /page-a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser keeps following redirects until it reaches its redirect limit and displays an error.&lt;/p&gt;

&lt;p&gt;Always test redirect destinations after changing your web server configuration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Forgetting to Preserve URL Paths and Query Strings
&lt;/h3&gt;

&lt;p&gt;When redirecting an entire website, make sure the original paths and query strings are preserved where required.&lt;/p&gt;

&lt;p&gt;In Nginx, &lt;code&gt;$request_uri&lt;/code&gt; can help retain both.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which HTTP Redirect Should You Use?
&lt;/h2&gt;

&lt;p&gt;As a general rule:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;301:&lt;/strong&gt; Use when a resource has permanently moved and preserving the original request method is not required.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;302:&lt;/strong&gt; Use when a resource has temporarily moved and preserving the original request method is not required.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;307:&lt;/strong&gt; Use when a resource has temporarily moved and the original request method must be preserved.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;308:&lt;/strong&gt; Use when a resource has permanently moved and the original request method must be preserved.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Choosing the correct redirect status code helps browsers, clients, and applications understand how they should handle the request.&lt;/p&gt;

&lt;p&gt;For everyday website URL changes, 301 and 302 are often sufficient. For API endpoints and applications that process different HTTP methods, 307 and 308 provide more predictable behaviour.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;HTTP redirects are a small but important part of running a website or application.&lt;/p&gt;

&lt;p&gt;Although 301, 302 and 307 responses all send clients to another URL, their behaviour isn't interchangeable. Understanding whether a redirect is permanent or temporary, and whether the original request method needs to be preserved, helps you choose the right response for your application.&lt;/p&gt;

&lt;p&gt;If you're working with Nginx, the &lt;code&gt;return&lt;/code&gt; directive makes configuring these redirects straightforward. Just remember to test your changes and check the response headers to confirm the server is returning the status code you intended.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTTP Redirect Commands Reference
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;curl -I https://example.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Inspect response headers and status codes.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;curl -L https://example.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Follow HTTP redirects.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;curl -v -L https://example.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Display detailed request and redirect information.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sudo nginx -t&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Test the Nginx configuration syntax.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sudo nginx -T&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Test and display the active Nginx configuration.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Further Reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.rfc-editor.org/rfc/rfc9110" rel="noopener noreferrer"&gt;RFC 9110 – HTTP Semantics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nginx.org/en/docs/http/ngx_http_rewrite_module.html" rel="noopener noreferrer"&gt;Nginx – Rewrite Module Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://curl.se/docs/" rel="noopener noreferrer"&gt;curl Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://devopsdrops.uk/articles/http-301-vs-302-vs-307?utm_source=devto&amp;amp;utm_medium=social&amp;amp;utm_campaign=distribution" rel="noopener noreferrer"&gt;The DevOps Drop&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>networking</category>
      <category>devops</category>
      <category>http</category>
      <category>webservers</category>
    </item>
    <item>
      <title>How to Inspect Nginx Error Logs: A Practical Troubleshooting Guide</title>
      <dc:creator>DevOps Drops</dc:creator>
      <pubDate>Sun, 06 Dec 2026 07:35:03 +0000</pubDate>
      <link>https://dev.to/devopsdrops/how-to-inspect-nginx-error-logs-a-practical-troubleshooting-guide-3bg2</link>
      <guid>https://dev.to/devopsdrops/how-to-inspect-nginx-error-logs-a-practical-troubleshooting-guide-3bg2</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;When a website becomes unavailable, returns unexpected HTTP errors, or behaves inconsistently, one of the first places to investigate is the web server's error log. For applications running behind &lt;strong&gt;Nginx&lt;/strong&gt;, these logs provide valuable information about what the server is experiencing when handling incoming requests.&lt;/p&gt;

&lt;p&gt;Nginx error logs record events such as failed upstream connections, permission problems, missing files, configuration errors, and resource limitations. Knowing how to locate and interpret these messages can significantly reduce the time spent diagnosing production issues.&lt;/p&gt;

&lt;p&gt;In this guide, we'll look at where Nginx stores its error logs, how to inspect them using standard Linux commands, how to filter relevant messages, and how to use log entries to investigate common problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Are Nginx Error Logs Stored?
&lt;/h2&gt;

&lt;p&gt;On most Linux installations, the default Nginx error log is located at:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/var/log/nginx/error.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The access log is usually stored alongside it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/var/log/nginx/access.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are common defaults on distributions such as Ubuntu and Debian, although the actual locations depend on the Nginx configuration and how the package was installed.&lt;/p&gt;

&lt;p&gt;To check which error log file Nginx is configured to use, inspect its configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo nginx -T &lt;span class="o"&gt;|&lt;/span&gt; grep -i error_log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;nginx -T&lt;/code&gt; command tests and dumps the complete active configuration, including configuration files loaded through included directives. This makes it useful when the error log directive is defined in a separate virtual host or included configuration file.&lt;/p&gt;

&lt;p&gt;Example output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="n"&gt;error_log&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;nginx&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="n"&gt;warn&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells us that Nginx writes error messages to &lt;code&gt;/var/log/nginx/error.log&lt;/code&gt; and uses the &lt;code&gt;warn&lt;/code&gt; logging level.&lt;/p&gt;

&lt;p&gt;Keep in mind that Nginx can have different error log destinations at different configuration levels. A server or location block may define its own error log, so inspecting the complete configuration is more reliable than checking only the main configuration file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Viewing Nginx Error Logs
&lt;/h2&gt;

&lt;p&gt;Linux provides several commands for inspecting log files. The most useful ones for day-to-day troubleshooting are &lt;code&gt;tail&lt;/code&gt;, &lt;code&gt;less&lt;/code&gt;, and &lt;code&gt;grep&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. View the Most Recent Log Entries
&lt;/h3&gt;

&lt;p&gt;To display the last 50 lines of the Nginx error log, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tail -n 50 /var/log/nginx/error.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is often the quickest way to identify a recent problem without reading the entire log file.&lt;/p&gt;

&lt;p&gt;You can increase the number of lines if you need more context:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tail -n 200 /var/log/nginx/error.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Follow the Log in Real Time
&lt;/h3&gt;

&lt;p&gt;When reproducing an issue, following the error log in real time is particularly useful:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tail -f /var/log/nginx/error.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;New log entries will appear as Nginx writes them. This allows you to trigger a request in your browser or with &lt;code&gt;curl&lt;/code&gt; and immediately inspect the resulting server messages.&lt;/p&gt;

&lt;p&gt;For example, in one terminal window:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tail -f /var/log/nginx/error.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In another terminal, make a request to the affected website:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -I https://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the request causes an error that Nginx records, you should see a corresponding entry in the log.&lt;/p&gt;

&lt;p&gt;Press &lt;code&gt;Ctrl + C&lt;/code&gt; to stop following the file.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Read the Log with Less
&lt;/h3&gt;

&lt;p&gt;For investigating older entries, &lt;code&gt;less&lt;/code&gt; is more convenient than printing the entire file to the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo less /var/log/nginx/error.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Useful keyboard shortcuts include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;G&lt;/code&gt; - Jump to the end of the file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;g&lt;/code&gt; - Jump to the beginning.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/pattern&lt;/code&gt; - Search for a specific word or phrase.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;n&lt;/code&gt; - Move to the next search result.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;N&lt;/code&gt; - Move to the previous search result.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;q&lt;/code&gt; - Exit.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Filtering Nginx Error Logs
&lt;/h2&gt;

&lt;p&gt;Production servers can generate a substantial amount of log output. Filtering the error log helps narrow an investigation down to relevant events.&lt;/p&gt;

&lt;h3&gt;
  
  
  Search for Specific Errors
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;grep&lt;/code&gt; command can search for a particular word or phrase:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo grep -i &lt;span class="s2"&gt;"error"&lt;/span&gt; /var/log/nginx/error.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-i&lt;/code&gt; option makes the search case-insensitive.&lt;/p&gt;

&lt;p&gt;You can also search for common Nginx error messages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo grep -i &lt;span class="s2"&gt;"permission denied"&lt;/span&gt; /var/log/nginx/error.log
sudo grep -i &lt;span class="s2"&gt;"connection refused"&lt;/span&gt; /var/log/nginx/error.log
sudo grep -i &lt;span class="s2"&gt;"upstream timed out"&lt;/span&gt; /var/log/nginx/error.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Combine Grep with Tail
&lt;/h3&gt;

&lt;p&gt;To follow the log while displaying only entries matching a particular pattern, combine &lt;code&gt;tail&lt;/code&gt; and &lt;code&gt;grep&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tail -f /var/log/nginx/error.log &lt;span class="o"&gt;|&lt;/span&gt; grep --line-buffered -i &lt;span class="s2"&gt;"upstream"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--line-buffered&lt;/code&gt; option helps ensure matching lines are displayed as they arrive, rather than being held in a buffer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Search for Errors Within a Time Period
&lt;/h3&gt;

&lt;p&gt;Nginx error log entries typically include timestamps. You can use these timestamps to narrow your investigation to a particular date or time.&lt;/p&gt;

&lt;p&gt;For example, to search for entries containing a specific date:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo grep &lt;span class="s2"&gt;"2026/12/01"&lt;/span&gt; /var/log/nginx/error.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace the date with the date you are investigating. The exact timestamp format depends on the log format and configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Nginx Error Log Messages
&lt;/h2&gt;

&lt;p&gt;Being able to read the log is only part of the process. Understanding what the messages mean is what helps you identify the underlying problem.&lt;/p&gt;

&lt;p&gt;A typical Nginx error log entry looks similar to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2026/12/01 10:15:32 [error] 1234#1234: *56 connect() failed (111: Connection refused) while connecting to upstream, client: 192.0.2.10, server: example.com, request: "GET /api/users HTTP/1.1", upstream: "http://127.0.0.1:8000/api/users", host: "example.com"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break down the important parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Timestamp:&lt;/strong&gt; &lt;code&gt;2026/12/01 10:15:32&lt;/code&gt; indicates when the event occurred.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Severity:&lt;/strong&gt; &lt;code&gt;[error]&lt;/code&gt; identifies the logging level.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Process and connection identifiers:&lt;/strong&gt; &lt;code&gt;1234#1234&lt;/code&gt; and &lt;code&gt;*56&lt;/code&gt; help identify the worker process and connection involved.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error description:&lt;/strong&gt; &lt;code&gt;connect() failed (111: Connection refused)&lt;/code&gt; describes the failure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Client:&lt;/strong&gt; The IP address of the client making the request.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server:&lt;/strong&gt; The Nginx server block handling the request.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Request:&lt;/strong&gt; The HTTP method, path, and protocol.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Upstream:&lt;/strong&gt; The backend address Nginx was attempting to contact.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This information can help you determine whether a problem originates in Nginx itself, the application behind it, or the connection between the two.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Nginx Errors and How to Investigate Them
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Connection Refused
&lt;/h3&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;connect() failed (111: Connection refused) while connecting to upstream
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This usually means Nginx attempted to connect to an upstream service, but the connection was actively refused.&lt;/p&gt;

&lt;p&gt;Possible causes include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The application process is not running.&lt;/li&gt;
&lt;li&gt;The application is listening on a different port.&lt;/li&gt;
&lt;li&gt;The upstream address is incorrect.&lt;/li&gt;
&lt;li&gt;The application is bound to a different network interface.&lt;/li&gt;
&lt;li&gt;A container or service dependency is unavailable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start by checking whether the application is running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl status php8.3-fpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace the service name with the actual service used by your application.&lt;/p&gt;

&lt;p&gt;Next, check whether the expected port is listening:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo ss -lntp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the application is expected to listen on port 8000, you can filter the output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo ss -lntp &lt;span class="o"&gt;|&lt;/span&gt; grep &lt;span class="s1"&gt;':8000'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For containerised applications, also check the container status and its logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker ps
docker logs &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;container_name&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Permission Denied
&lt;/h3&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;open() "/var/www/html/index.html" failed (13: Permission denied)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This indicates that Nginx attempted to access a file or directory but did not have the necessary permissions.&lt;/p&gt;

&lt;p&gt;Common causes include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Incorrect ownership of application files.&lt;/li&gt;
&lt;li&gt;File permissions preventing the Nginx worker process from reading content.&lt;/li&gt;
&lt;li&gt;Missing execute permissions on one of the parent directories.&lt;/li&gt;
&lt;li&gt;Security restrictions imposed by SELinux or AppArmor.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check the permissions of the affected file and its parent directories:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -l /var/www/html/index.html
namei -l /var/www/html/index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;namei&lt;/code&gt; command is particularly useful because it shows permissions along the entire directory path.&lt;/p&gt;

&lt;p&gt;Do not immediately resolve permission errors by applying broad permissions such as &lt;code&gt;chmod -R 777&lt;/code&gt;. Instead, identify which user Nginx runs as and grant only the access required.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Upstream Timed Out
&lt;/h3&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;upstream timed out (110: Connection timed out) while reading response header from upstream
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means Nginx did not receive the expected response from the upstream service within the configured timeout.&lt;/p&gt;

&lt;p&gt;Possible causes include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Slow application requests.&lt;/li&gt;
&lt;li&gt;Database queries taking too long.&lt;/li&gt;
&lt;li&gt;Insufficient application worker capacity.&lt;/li&gt;
&lt;li&gt;An overloaded backend server.&lt;/li&gt;
&lt;li&gt;Network connectivity problems between Nginx and the upstream.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start by inspecting the application logs at the same timestamp. If the application uses PHP-FPM, check its service logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo journalctl -u php8.3-fpm --since &lt;span class="s2"&gt;"10 minutes ago"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also inspect system resource usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;top
free -h
df -h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Increasing Nginx timeout values may sometimes be appropriate, but it should not be the first response. A timeout can be a symptom of a slow or unhealthy backend, and increasing the limit may simply make requests wait longer.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. No Such File or Directory
&lt;/h3&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;open() "/var/www/html/assets/app.css" failed (2: No such file or directory)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means Nginx attempted to access a file that does not exist at the resolved path.&lt;/p&gt;

&lt;p&gt;Check the relevant &lt;code&gt;root&lt;/code&gt; or &lt;code&gt;alias&lt;/code&gt; directive in the server configuration, then verify that the requested file exists:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -l /var/www/html/assets/app.css
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For applications using a deployment pipeline, check whether the latest release contains the expected assets and whether Nginx is pointing at the correct release directory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Nginx Logging Levels
&lt;/h2&gt;

&lt;p&gt;Nginx supports several error log severity levels. These determine which messages are written to the configured error log.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Level&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;debug&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Detailed diagnostic information, useful for investigating complex issues.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;info&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Informational messages about server activity.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;notice&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Normal but significant events.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;warn&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Warning messages that may indicate a potential problem.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;error&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Error conditions that require attention.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;crit&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Critical conditions.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;alert&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Conditions requiring immediate action.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;emerg&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Emergency conditions where the system may be unusable.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For example, the following directive sets the error log level to &lt;code&gt;warn&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="n"&gt;error_log&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;nginx&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="n"&gt;warn&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Changing the level to &lt;code&gt;debug&lt;/code&gt; can provide more detailed information when investigating difficult problems:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="n"&gt;error_log&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;nginx&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt; &lt;span class="n"&gt;debug&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, debug logging can generate a large amount of output and may affect performance. It also requires an Nginx build compiled with the debug support option. Use it temporarily and only when necessary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checking Logs Through systemd
&lt;/h2&gt;

&lt;p&gt;Depending on how Nginx was installed and configured, some service messages may also be available through the systemd journal.&lt;/p&gt;

&lt;p&gt;To inspect recent Nginx service logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo journalctl -u nginx -n 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To follow new journal entries in real time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo journalctl -u nginx -f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To inspect messages from a particular period:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo journalctl -u nginx --since &lt;span class="s2"&gt;"1 hour ago"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The journal is useful for investigating service startup failures, configuration problems, and events recorded by the service manager. It does not necessarily contain every request-level error recorded in Nginx's configured error log.&lt;/p&gt;

&lt;h2&gt;
  
  
  Managing Log Rotation
&lt;/h2&gt;

&lt;p&gt;Nginx error logs can grow over time, especially on busy production servers. Without log rotation, they can consume a significant amount of disk space.&lt;/p&gt;

&lt;p&gt;Many Linux package installations configure log rotation through &lt;code&gt;logrotate&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Check whether an Nginx log rotation configuration exists:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cat /etc/logrotate.d/nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A typical configuration may look similar to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/var/log/nginx/*.log {
    daily
    missingok
    rotate 14
    compress
    delaycompress
    notifempty
    create 0640 www-data adm
    sharedscripts
    postrotate
        if [ -f /run/nginx.pid ]; then
            kill -USR1 $(cat /run/nginx.pid)
        fi
    endscript
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example rotates logs daily, keeps 14 rotations, compresses older files, and signals Nginx to reopen its log files after rotation.&lt;/p&gt;

&lt;p&gt;The exact configuration can vary by distribution. The important point is that Nginx needs to reopen its log files after rotation so it does not continue writing to an old file descriptor.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Practical Nginx Troubleshooting Workflow
&lt;/h2&gt;

&lt;p&gt;When investigating a production issue, it helps to follow a consistent process rather than immediately changing configuration settings.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Reproduce the issue:&lt;/strong&gt; Make a request to the affected URL and record the approximate time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inspect the error log:&lt;/strong&gt; Use &lt;code&gt;tail -f&lt;/code&gt; or &lt;code&gt;tail -n 100&lt;/code&gt; to look for new messages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Identify the failure:&lt;/strong&gt; Look for connection errors, permission problems, missing files, or upstream timeouts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check the relevant service:&lt;/strong&gt; Inspect Nginx, PHP-FPM, application, database, or container logs as appropriate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verify the underlying cause:&lt;/strong&gt; Check connectivity, permissions, ports, resource usage, and application health.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Apply a targeted fix:&lt;/strong&gt; Change only what is necessary to resolve the issue.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retest:&lt;/strong&gt; Repeat the original request and confirm that the error no longer appears.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For example, if a website returns a &lt;code&gt;502 Bad Gateway&lt;/code&gt; response, the Nginx error log may reveal that the upstream connection was refused. Rather than changing the Nginx configuration immediately, investigate whether the application service is running and listening on the expected address and port.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Nginx error logs are one of the most useful tools available when diagnosing web server problems. They provide insight into failed upstream connections, permission issues, missing files, timeout conditions, and other events that can affect application availability.&lt;/p&gt;

&lt;p&gt;Commands such as &lt;code&gt;tail&lt;/code&gt;, &lt;code&gt;less&lt;/code&gt;, &lt;code&gt;grep&lt;/code&gt;, and &lt;code&gt;journalctl&lt;/code&gt; make it straightforward to inspect log output, investigate recent failures, and monitor server behaviour while reproducing an issue.&lt;/p&gt;

&lt;p&gt;For DevOps engineers, regularly reviewing server logs and understanding what common error messages mean is an important part of maintaining reliable web infrastructure. Rather than treating every error as an Nginx configuration problem, use the information in the logs to trace failures back to their actual source.&lt;/p&gt;

&lt;h2&gt;
  
  
  Useful Commands Reference
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sudo tail -n 50 /var/log/nginx/error.log&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;View the latest 50 error log entries.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sudo tail -f /var/log/nginx/error.log&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Follow the error log in real time.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sudo less /var/log/nginx/error.log&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Browse the log interactively.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sudo grep -i "error" /var/log/nginx/error.log&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Search for matching error messages.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sudo nginx -T&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Test and dump the active Nginx configuration.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sudo nginx -t&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Test the Nginx configuration syntax.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sudo journalctl -u nginx -f&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Follow Nginx service messages in systemd.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sudo ss -lntp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Inspect listening TCP ports and processes.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://devopsdrops.uk/articles/inspect-nginx-error-logs?utm_source=devto&amp;amp;utm_medium=social&amp;amp;utm_campaign=distribution" rel="noopener noreferrer"&gt;The DevOps Drop&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>webservers</category>
      <category>troubleshooting</category>
    </item>
    <item>
      <title>Understanding HTTP Status Codes</title>
      <dc:creator>DevOps Drops</dc:creator>
      <pubDate>Sun, 06 Dec 2026 07:28:35 +0000</pubDate>
      <link>https://dev.to/devopsdrops/understanding-http-status-codes-3n58</link>
      <guid>https://dev.to/devopsdrops/understanding-http-status-codes-3n58</guid>
      <description>&lt;h2&gt;
  
  
  HTTP Errors Decoded: How DevOps Engineers Debug Web Application Failures
&lt;/h2&gt;

&lt;p&gt;HTTP status codes are one of the most important tools for understanding how web applications communicate. Every time a browser loads a page, an API request is made, or a service communicates with another system, HTTP status codes provide information about what happened during that request.&lt;/p&gt;

&lt;p&gt;At their simplest, HTTP status codes are three-digit numbers returned by a web server to describe the result of a request. They help developers, system administrators, and DevOps engineers quickly identify whether a request succeeded, failed, or requires further investigation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Do HTTP Status Codes Matter?
&lt;/h2&gt;

&lt;p&gt;Modern applications are built from many interconnected services. A user request might pass through a browser, CDN, load balancer, web server, API gateway, application server, and database before a response is returned.&lt;/p&gt;

&lt;p&gt;When something breaks, HTTP status codes provide the first clue about where the problem might be.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="no"&gt;OK&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;means the request completed successfully, while:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;500 Internal Server Error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;indicates that something went wrong inside the application.&lt;/p&gt;

&lt;p&gt;Understanding these codes allows DevOps teams to troubleshoot issues faster and determine whether a problem exists in the client, network, infrastructure, or application layer.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Five Categories of HTTP Status Codes
&lt;/h2&gt;

&lt;p&gt;HTTP status codes are grouped into five main categories. The first digit represents the category.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;1xx - Informational responses&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2xx - Successful responses&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;3xx - Redirection responses&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;4xx - Client error responses&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;5xx - Server error responses&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1xx Informational Responses
&lt;/h2&gt;

&lt;p&gt;1xx responses are informational messages. They indicate that the server has received the request and is continuing to process it.&lt;/p&gt;

&lt;p&gt;These responses are less commonly seen during normal application debugging.&lt;/p&gt;

&lt;h3&gt;
  
  
  100 Continue
&lt;/h3&gt;

&lt;p&gt;The client can continue sending the request body after receiving permission from the server.&lt;/p&gt;

&lt;p&gt;This is commonly used with large requests where the client wants to verify that the server will accept the request before uploading the full content.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt; &lt;span class="nc"&gt;Continue&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2xx Successful Responses
&lt;/h2&gt;

&lt;p&gt;2xx responses indicate that the request was successfully received, understood, and processed.&lt;/p&gt;

&lt;h3&gt;
  
  
  200 OK
&lt;/h3&gt;

&lt;p&gt;The most common successful response. It means the request completed successfully.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;GET&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;123&lt;/span&gt;

&lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="no"&gt;OK&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This response is commonly returned when loading pages, retrieving API data, or completing operations.&lt;/p&gt;

&lt;h3&gt;
  
  
  201 Created
&lt;/h3&gt;

&lt;p&gt;A 201 response indicates that a new resource was successfully created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;

&lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt; &lt;span class="mi"&gt;201&lt;/span&gt; &lt;span class="nc"&gt;Created&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;REST APIs often return this after creating a new database record.&lt;/p&gt;

&lt;h3&gt;
  
  
  204 No Content
&lt;/h3&gt;

&lt;p&gt;A 204 response means the request succeeded but there is no response body to return.&lt;/p&gt;

&lt;p&gt;This is commonly used for delete operations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;DELETE&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;123&lt;/span&gt;

&lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt; &lt;span class="mi"&gt;204&lt;/span&gt; &lt;span class="nc"&gt;No&lt;/span&gt; &lt;span class="nc"&gt;Content&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3xx Redirection Responses
&lt;/h2&gt;

&lt;p&gt;3xx responses tell the client that additional action is required before completing the request.&lt;/p&gt;

&lt;h3&gt;
  
  
  301 Moved Permanently
&lt;/h3&gt;

&lt;p&gt;A 301 response indicates that a resource has permanently moved to another location.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;example.com → www.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is commonly used when redirecting old URLs to new ones.&lt;/p&gt;

&lt;h3&gt;
  
  
  302 Found
&lt;/h3&gt;

&lt;p&gt;A 302 response indicates a temporary redirect.&lt;/p&gt;

&lt;p&gt;Common examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Redirecting users after login&lt;/li&gt;
&lt;li&gt;Temporary maintenance pages&lt;/li&gt;
&lt;li&gt;Moving traffic between environments&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4xx Client Error Responses
&lt;/h2&gt;

&lt;p&gt;4xx errors indicate that the request was not valid or the client does not have permission to complete the action.&lt;/p&gt;

&lt;h3&gt;
  
  
  400 Bad Request
&lt;/h3&gt;

&lt;p&gt;A 400 response means the server cannot understand the request because it contains invalid data.&lt;/p&gt;

&lt;p&gt;Common causes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Malformed JSON&lt;/li&gt;
&lt;li&gt;Missing required fields&lt;/li&gt;
&lt;li&gt;Invalid query parameters
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"invalid-email"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  401 Unauthorized
&lt;/h3&gt;

&lt;p&gt;A 401 response means authentication is required or the provided credentials are invalid.&lt;/p&gt;

&lt;p&gt;Common causes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Missing API token&lt;/li&gt;
&lt;li&gt;Expired session&lt;/li&gt;
&lt;li&gt;Invalid credentials&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  403 Forbidden
&lt;/h3&gt;

&lt;p&gt;A 403 response means the user is authenticated but does not have permission to access the resource.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;normal_user&lt;/span&gt;

&lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="no"&gt;DELETE&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;admin&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;123&lt;/span&gt;

&lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="mi"&gt;403&lt;/span&gt; &lt;span class="nc"&gt;Forbidden&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  404 Not Found
&lt;/h3&gt;

&lt;p&gt;A 404 response means the requested resource does not exist.&lt;/p&gt;

&lt;p&gt;Common causes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Incorrect URL&lt;/li&gt;
&lt;li&gt;Deleted resources&lt;/li&gt;
&lt;li&gt;Incorrect API routes
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;GET&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;999999&lt;/span&gt;

&lt;span class="mi"&gt;404&lt;/span&gt; &lt;span class="nc"&gt;Not&lt;/span&gt; &lt;span class="nc"&gt;Found&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5xx Server Error Responses
&lt;/h2&gt;

&lt;p&gt;5xx responses indicate that the server failed while processing a valid request.&lt;/p&gt;

&lt;p&gt;These errors are usually the responsibility of the application or infrastructure team.&lt;/p&gt;

&lt;h3&gt;
  
  
  500 Internal Server Error
&lt;/h3&gt;

&lt;p&gt;A 500 response is a generic server-side failure.&lt;/p&gt;

&lt;p&gt;Common causes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unhandled application exceptions&lt;/li&gt;
&lt;li&gt;Database failures&lt;/li&gt;
&lt;li&gt;Incorrect configuration&lt;/li&gt;
&lt;li&gt;Application bugs
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt; &lt;span class="nc"&gt;Internal&lt;/span&gt; &lt;span class="nc"&gt;Server&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  502 Bad Gateway
&lt;/h3&gt;

&lt;p&gt;A 502 response usually means that one service received an invalid response from another service.&lt;/p&gt;

&lt;p&gt;This commonly happens with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Load balancers&lt;/li&gt;
&lt;li&gt;Reverse proxies&lt;/li&gt;
&lt;li&gt;API gateways&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Nginx → Application Server

Application Server crashes

Nginx returns:

502 Bad Gateway
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  503 Service Unavailable
&lt;/h3&gt;

&lt;p&gt;A 503 response means the server is temporarily unable to handle requests.&lt;/p&gt;

&lt;p&gt;Common causes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Server maintenance&lt;/li&gt;
&lt;li&gt;High traffic&lt;/li&gt;
&lt;li&gt;Application overload&lt;/li&gt;
&lt;li&gt;Failed health checks&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  504 Gateway Timeout
&lt;/h3&gt;

&lt;p&gt;A 504 response occurs when a gateway or proxy waits too long for another service to respond.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client
 |
Load Balancer
 |
API Server
 |
Database (slow)

Result:
504 Gateway Timeout
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Debugging HTTP Errors From The Command Line
&lt;/h2&gt;

&lt;p&gt;DevOps engineers often use command-line tools to inspect HTTP responses directly.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;curl&lt;/code&gt; command is one of the most useful tools for debugging HTTP requests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -I https://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-I&lt;/code&gt; option displays only the response headers.&lt;/p&gt;

&lt;p&gt;You can also inspect detailed request information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -v https://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This shows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Request headers&lt;/li&gt;
&lt;li&gt;Response headers&lt;/li&gt;
&lt;li&gt;TLS information&lt;/li&gt;
&lt;li&gt;Connection details&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  HTTP Status Codes in Monitoring and Observability
&lt;/h2&gt;

&lt;p&gt;HTTP status codes are essential metrics in production monitoring systems.&lt;/p&gt;

&lt;p&gt;DevOps teams commonly track:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Error rate&lt;/li&gt;
&lt;li&gt;Request latency&lt;/li&gt;
&lt;li&gt;Availability&lt;/li&gt;
&lt;li&gt;Traffic volume&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, a sudden increase in 500 errors might indicate an application deployment problem.&lt;/p&gt;

&lt;p&gt;A spike in 404 errors could indicate broken links, incorrect routing, or a failed frontend deployment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common HTTP Debugging Workflow
&lt;/h2&gt;

&lt;p&gt;When investigating a failed request, a typical troubleshooting process looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Identify the HTTP status code.&lt;/li&gt;
&lt;li&gt;Check application and server logs.&lt;/li&gt;
&lt;li&gt;Verify network connectivity.&lt;/li&gt;
&lt;li&gt;Inspect recent deployments or configuration changes.&lt;/li&gt;
&lt;li&gt;Check dependent services such as databases and APIs.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For example, a 500 error might require checking application logs, while a 502 error may require investigating communication between services.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why HTTP Status Codes Matter For DevOps
&lt;/h2&gt;

&lt;p&gt;HTTP status codes provide a common language between developers, operations teams, and monitoring tools.&lt;/p&gt;

&lt;p&gt;A strong understanding of HTTP responses helps with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Troubleshooting production incidents&lt;/li&gt;
&lt;li&gt;Building reliable APIs&lt;/li&gt;
&lt;li&gt;Configuring reverse proxies&lt;/li&gt;
&lt;li&gt;Creating effective monitoring alerts&lt;/li&gt;
&lt;li&gt;Improving application reliability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Many production problems can be diagnosed faster by understanding what a status code reveals about the failing component.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;HTTP status codes are more than simple numbers returned by a server. They provide valuable insight into how web applications behave and where problems occur.&lt;/p&gt;

&lt;p&gt;For DevOps engineers, understanding the difference between client errors, server errors, redirects, and successful responses is a fundamental skill for debugging modern web systems.&lt;/p&gt;

&lt;p&gt;Whether troubleshooting an API failure, investigating downtime, or monitoring production services, HTTP status codes are one of the first places to look.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://devopsdrops.uk/articles/understanding-http-status-codes-devops-guide?utm_source=devto&amp;amp;utm_medium=social&amp;amp;utm_campaign=distribution" rel="noopener noreferrer"&gt;The DevOps Drop&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>networking</category>
      <category>devops</category>
      <category>http</category>
      <category>webservers</category>
    </item>
    <item>
      <title>How DNS Actually Works</title>
      <dc:creator>DevOps Drops</dc:creator>
      <pubDate>Sun, 06 Dec 2026 07:28:32 +0000</pubDate>
      <link>https://dev.to/devopsdrops/how-dns-actually-works-ig</link>
      <guid>https://dev.to/devopsdrops/how-dns-actually-works-ig</guid>
      <description>&lt;h2&gt;
  
  
  What is DNS and How Does It Actually Work?
&lt;/h2&gt;

&lt;p&gt;DNS (Domain Name System) is one of the most important technologies that powers the internet. Every time you visit a website, send an email, or connect to an online service, DNS is usually involved behind the scenes.&lt;/p&gt;

&lt;p&gt;At its simplest, DNS acts like the phonebook of the internet. Humans prefer memorable names like &lt;strong&gt;google.com&lt;/strong&gt;, while computers communicate using IP addresses such as &lt;code&gt;142.250.74.14&lt;/code&gt;. DNS bridges the gap between these two.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Do We Need DNS?
&lt;/h2&gt;

&lt;p&gt;Computers are perfectly happy communicating with IP addresses, but remembering an address for every service we use would be impossible.&lt;/p&gt;

&lt;p&gt;Imagine having to remember:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;142.250.74.14
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;DNS allows us to use human-readable domain names while automatically finding the correct destination.&lt;/p&gt;

&lt;h2&gt;
  
  
  The DNS Lookup Process
&lt;/h2&gt;

&lt;p&gt;When you enter a domain name into your browser, several systems work together to find the correct IP address.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Your device checks its local DNS cache.&lt;/li&gt;
&lt;li&gt;If no result exists, the request is sent to a recursive DNS resolver.&lt;/li&gt;
&lt;li&gt;The resolver queries the DNS hierarchy.&lt;/li&gt;
&lt;li&gt;The authoritative DNS server returns the final answer.&lt;/li&gt;
&lt;li&gt;The browser connects to the returned IP address.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The DNS Hierarchy
&lt;/h2&gt;

&lt;p&gt;DNS is not controlled by one giant database. Instead, it is distributed across multiple levels.&lt;/p&gt;

&lt;h3&gt;
  
  
  Root Name Servers
&lt;/h3&gt;

&lt;p&gt;At the top of the DNS hierarchy are root name servers. They do not know the IP address of every website, but they know where to find information about top-level domains.&lt;/p&gt;

&lt;p&gt;For example, when looking up:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The root server points the resolver towards the servers responsible for the &lt;strong&gt;.com&lt;/strong&gt; domain.&lt;/p&gt;

&lt;h3&gt;
  
  
  TLD Name Servers
&lt;/h3&gt;

&lt;p&gt;Top-level domain (TLD) servers handle domains such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;.com&lt;/li&gt;
&lt;li&gt;.net&lt;/li&gt;
&lt;li&gt;.org&lt;/li&gt;
&lt;li&gt;.uk&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The TLD server then points the resolver towards the authoritative name server for the specific domain.&lt;/p&gt;

&lt;h3&gt;
  
  
  Authoritative Name Servers
&lt;/h3&gt;

&lt;p&gt;The authoritative DNS server contains the actual DNS records for a domain.&lt;/p&gt;

&lt;p&gt;Example records:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A       example.com        192.0.2.10
AAAA    example.com        2001:db8::10
CNAME   www.example.com    example.com
MX      example.com        mail.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Common DNS Record Types
&lt;/h2&gt;

&lt;h3&gt;
  
  
  A Record
&lt;/h3&gt;

&lt;p&gt;An A record maps a domain name to an IPv4 address.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;example.com → 192.0.2.10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  AAAA Record
&lt;/h3&gt;

&lt;p&gt;An AAAA record performs the same job as an A record but for IPv6 addresses.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;example.com → 2001:db8::10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  CNAME Record
&lt;/h3&gt;

&lt;p&gt;A CNAME creates an alias from one domain to another.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;www.example.com → example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  MX Record
&lt;/h3&gt;

&lt;p&gt;Mail exchange records tell email servers where to deliver messages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;example.com → mail.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Testing DNS From The Command Line
&lt;/h2&gt;

&lt;p&gt;As a developer or system administrator, you will often need to troubleshoot DNS issues.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;dig&lt;/code&gt; command is one of the most useful tools available.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also query specific record types:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig example.com A

dig example.com MX

dig example.com TXT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  DNS Propagation
&lt;/h2&gt;

&lt;p&gt;When you update a DNS record, the change is not always visible immediately. This is because DNS responses are cached around the world.&lt;/p&gt;

&lt;p&gt;Each DNS record has a TTL (Time To Live) value, which tells resolvers how long they should cache the response before requesting fresh information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TTL: 3600
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A TTL of 3600 means the record can be cached for one hour.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why DNS Matters For DevOps
&lt;/h2&gt;

&lt;p&gt;DNS is often overlooked because it usually works quietly in the background, but it is critical for modern infrastructure.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deploying applications behind domains&lt;/li&gt;
&lt;li&gt;Configuring load balancers&lt;/li&gt;
&lt;li&gt;Setting up SSL certificates&lt;/li&gt;
&lt;li&gt;Routing traffic between services&lt;/li&gt;
&lt;li&gt;Managing Kubernetes ingress&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A strong understanding of DNS makes troubleshooting production systems significantly easier. Many "the website is down" issues eventually lead back to DNS configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;DNS is one of the foundations of the internet. Although the system is complex underneath, the core idea is simple: translate human-friendly names into machine-friendly addresses.&lt;/p&gt;

&lt;p&gt;For anyone working in DevOps, networking, or cloud infrastructure, understanding DNS is a skill that will pay off repeatedly throughout your career.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://devopsdrops.uk/articles/how-dns-actually-works?utm_source=devto&amp;amp;utm_medium=social&amp;amp;utm_campaign=distribution" rel="noopener noreferrer"&gt;The DevOps Drop&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>dns</category>
      <category>networking</category>
      <category>infrastructure</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
