<?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>Forem: Tahsin Abrar</title>
    <description>The latest articles on Forem by Tahsin Abrar (@tahsin000).</description>
    <link>https://forem.com/tahsin000</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1084553%2Fd57c59ef-8617-4868-a1e8-7fe07493b0be.png</url>
      <title>Forem: Tahsin Abrar</title>
      <link>https://forem.com/tahsin000</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/tahsin000"/>
    <language>en</language>
    <item>
      <title>Stack Pointer vs Base Pointer: A Friendly Guide to How Function Calls Work</title>
      <dc:creator>Tahsin Abrar</dc:creator>
      <pubDate>Mon, 18 May 2026 11:38:49 +0000</pubDate>
      <link>https://forem.com/tahsin000/stack-pointer-vs-base-pointer-a-friendly-guide-to-how-function-calls-work-35nc</link>
      <guid>https://forem.com/tahsin000/stack-pointer-vs-base-pointer-a-friendly-guide-to-how-function-calls-work-35nc</guid>
      <description>&lt;p&gt;Have you ever called a function and wondered what really happens inside the computer?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;
    &lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sum&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;We know the output will be:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;But inside the machine, a lot of quiet work happens.&lt;/p&gt;

&lt;p&gt;The CPU needs to remember:&lt;/p&gt;

&lt;p&gt;Where did this function start?&lt;/p&gt;

&lt;p&gt;Where should it return?&lt;/p&gt;

&lt;p&gt;Where are the arguments?&lt;/p&gt;

&lt;p&gt;Where are the local variables?&lt;/p&gt;

&lt;p&gt;Which function is currently running?&lt;/p&gt;

&lt;p&gt;This is where the &lt;strong&gt;stack&lt;/strong&gt;, &lt;strong&gt;stack frame&lt;/strong&gt;, &lt;strong&gt;stack pointer&lt;/strong&gt;, and &lt;strong&gt;base pointer&lt;/strong&gt; come in.&lt;/p&gt;

&lt;p&gt;Let’s break them down in a simple way.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzo4q6ug2zami8jfwpmdf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzo4q6ug2zami8jfwpmdf.png" alt="diagram" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  First, What Is a Stack?
&lt;/h2&gt;

&lt;p&gt;A stack is a special area of memory used while a program is running.&lt;/p&gt;

&lt;p&gt;Think of it like a stack of plates.&lt;/p&gt;

&lt;p&gt;You put a plate on top.&lt;/p&gt;

&lt;p&gt;You remove the top plate first.&lt;/p&gt;

&lt;p&gt;You cannot remove a plate from the middle without disturbing the others.&lt;/p&gt;

&lt;p&gt;In programming, the stack works in a similar way.&lt;/p&gt;

&lt;p&gt;When a function is called, the program creates a small memory area for that function. This small area is called a &lt;strong&gt;stack frame&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When the function finishes, its stack frame is removed.&lt;/p&gt;

&lt;p&gt;So if &lt;code&gt;main()&lt;/code&gt; calls &lt;code&gt;add()&lt;/code&gt;, the stack may look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add() stack frame
main() stack frame
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;add()&lt;/code&gt; is on top because it is currently running.&lt;/p&gt;

&lt;p&gt;When &lt;code&gt;add()&lt;/code&gt; finishes, its stack frame is removed, and the program returns to &lt;code&gt;main()&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is a Stack Frame?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;stack frame&lt;/strong&gt; is the memory space a function gets while it is running.&lt;/p&gt;

&lt;p&gt;It usually stores things like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Function arguments
Return address
Old base pointer
Local variables
Temporary values
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For our &lt;code&gt;add()&lt;/code&gt; function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The stack frame may contain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = 10
y = 4
return address
old base pointer
result = 14
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The exact layout depends on the CPU, compiler, operating system, and calling convention. But the main idea is the same:&lt;/p&gt;

&lt;p&gt;A function needs a private workspace while it runs.&lt;/p&gt;

&lt;p&gt;That workspace is its stack frame.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Quick Note About Memory Addresses
&lt;/h2&gt;

&lt;p&gt;Before we go deeper, let’s clear up one common confusion.&lt;/p&gt;

&lt;p&gt;On most modern systems, memory is &lt;strong&gt;byte-addressable&lt;/strong&gt;. That means every byte has its own address.&lt;/p&gt;

&lt;p&gt;So memory addresses can look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0, 1, 2, 3, 4, 5, 6, 7, 8 ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But when we draw memory in larger chunks, like 4-byte chunks on a 32-bit-style example, we often label them like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0, 4, 8, 12, 16 ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This does &lt;strong&gt;not&lt;/strong&gt; mean addresses &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;2&lt;/code&gt;, and &lt;code&gt;3&lt;/code&gt; do not exist.&lt;/p&gt;

&lt;p&gt;It simply means we are drawing memory in 4-byte blocks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Address 0  -&amp;gt; byte 1 of first block
Address 1  -&amp;gt; byte 2 of first block
Address 2  -&amp;gt; byte 3 of first block
Address 3  -&amp;gt; byte 4 of first block

Address 4  -&amp;gt; byte 1 of second block
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For this article, we will use a simple 32-bit mental model where each slot is 4 bytes.&lt;/p&gt;

&lt;p&gt;So our stack addresses may move like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;80
76
72
68
64
60
56
52
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In many systems, the stack grows downward, which means the address gets smaller as new data is pushed onto the stack.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is the Stack Pointer?
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;stack pointer&lt;/strong&gt;, often called &lt;code&gt;SP&lt;/code&gt;, points to the current top of the stack.&lt;/p&gt;

&lt;p&gt;Imagine you are stacking plates.&lt;/p&gt;

&lt;p&gt;The stack pointer is like your finger pointing at the top plate.&lt;/p&gt;

&lt;p&gt;When a new value is pushed onto the stack, the stack pointer moves.&lt;/p&gt;

&lt;p&gt;When a value is popped from the stack, the stack pointer moves back.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Before push:

Address 76 -&amp;gt; old value
Address 72 -&amp;gt; top of stack  &amp;lt;- SP

Push new value:

Address 76 -&amp;gt; old value
Address 72 -&amp;gt; old top
Address 68 -&amp;gt; new value     &amp;lt;- SP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because our example stack grows downward, pushing data makes &lt;code&gt;SP&lt;/code&gt; move from &lt;code&gt;72&lt;/code&gt; to &lt;code&gt;68&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So the stack pointer is dynamic.&lt;/p&gt;

&lt;p&gt;It keeps changing as the stack grows and shrinks.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is the Base Pointer?
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;base pointer&lt;/strong&gt;, often called &lt;code&gt;BP&lt;/code&gt; or frame pointer, points to a stable location inside the current function’s stack frame.&lt;/p&gt;

&lt;p&gt;Unlike the stack pointer, the base pointer usually stays fixed while the function is running.&lt;/p&gt;

&lt;p&gt;Why do we need that?&lt;/p&gt;

&lt;p&gt;Because the stack pointer keeps moving.&lt;/p&gt;

&lt;p&gt;If the program only used &lt;code&gt;SP&lt;/code&gt;, it would be hard to find local variables and arguments after more values are pushed or popped.&lt;/p&gt;

&lt;p&gt;The base pointer solves this problem.&lt;/p&gt;

&lt;p&gt;It gives the function a fixed reference point.&lt;/p&gt;

&lt;p&gt;From that fixed point, the program can find values using offsets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BP + 8   -&amp;gt; first argument
BP + 12  -&amp;gt; second argument
BP - 4   -&amp;gt; first local variable
BP - 8   -&amp;gt; second local variable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So the base pointer helps the program answer questions like:&lt;/p&gt;

&lt;p&gt;Where is &lt;code&gt;x&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;Where is &lt;code&gt;y&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;Where is &lt;code&gt;result&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;Where should I return after this function ends?&lt;/p&gt;




&lt;h2&gt;
  
  
  Stack Pointer vs Base Pointer
&lt;/h2&gt;

&lt;p&gt;Here is the simple difference:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Register&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;Behavior&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Stack Pointer&lt;/td&gt;
&lt;td&gt;Points to the current top of the stack&lt;/td&gt;
&lt;td&gt;Changes often&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Base Pointer&lt;/td&gt;
&lt;td&gt;Points to a fixed place in the current stack frame&lt;/td&gt;
&lt;td&gt;Usually stays fixed during the function&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A simple way to remember it:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SP&lt;/code&gt; tracks movement.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;BP&lt;/code&gt; gives stability.&lt;/p&gt;

&lt;p&gt;The stack pointer is like a moving bookmark.&lt;/p&gt;

&lt;p&gt;The base pointer is like an anchor.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Happens When &lt;code&gt;main()&lt;/code&gt; Runs?
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;
    &lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sum&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 &lt;code&gt;main()&lt;/code&gt; starts, the program creates a stack frame for &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Inside that frame, it stores local variables such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 10
sum = ?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first, &lt;code&gt;sum&lt;/code&gt; does not have its final value because &lt;code&gt;add(a, 4)&lt;/code&gt; has not returned yet.&lt;/p&gt;

&lt;p&gt;So the stack may look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main stack frame
----------------
return address
old BP
a = 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now &lt;code&gt;main()&lt;/code&gt; calls &lt;code&gt;add(a, 4)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That means the program needs a new stack frame for &lt;code&gt;add()&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Happens When &lt;code&gt;add()&lt;/code&gt; Is Called?
&lt;/h2&gt;

&lt;p&gt;This line is important:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The program needs to call &lt;code&gt;add()&lt;/code&gt; with two values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = 10
y = 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So it creates a new stack frame for &lt;code&gt;add()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A simplified stack frame may look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add stack frame
---------------
y = 4
x = 10
return address
old BP
result = 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The order can vary depending on the system, but the idea is the same.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;add()&lt;/code&gt; function needs:&lt;/p&gt;

&lt;p&gt;Its arguments: &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A return address: where to go back after &lt;code&gt;add()&lt;/code&gt; finishes&lt;/p&gt;

&lt;p&gt;The old base pointer: so the caller’s stack frame can be restored&lt;/p&gt;

&lt;p&gt;Its local variable: &lt;code&gt;result&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Do We Need a Return Address?
&lt;/h2&gt;

&lt;p&gt;When &lt;code&gt;main()&lt;/code&gt; calls &lt;code&gt;add()&lt;/code&gt;, the CPU jumps to the code for &lt;code&gt;add()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;But after &lt;code&gt;add()&lt;/code&gt; finishes, the CPU must know where to go back.&lt;/p&gt;

&lt;p&gt;It needs to return to this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;More specifically, it needs to return to the next step after the function call, so the returned value can be stored in &lt;code&gt;sum&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That “go back here” location is called the &lt;strong&gt;return address&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Without a return address, the program would get lost.&lt;/p&gt;

&lt;p&gt;It would finish &lt;code&gt;add()&lt;/code&gt; and then have no idea where to continue.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Save the Old Base Pointer?
&lt;/h2&gt;

&lt;p&gt;Before &lt;code&gt;add()&lt;/code&gt; starts, &lt;code&gt;main()&lt;/code&gt; already has its own base pointer.&lt;/p&gt;

&lt;p&gt;When &lt;code&gt;add()&lt;/code&gt; starts, it gets a new base pointer for its own stack frame.&lt;/p&gt;

&lt;p&gt;But when &lt;code&gt;add()&lt;/code&gt; finishes, the program must restore the old base pointer so &lt;code&gt;main()&lt;/code&gt; can continue correctly.&lt;/p&gt;

&lt;p&gt;That is why the old base pointer is saved inside the new stack frame.&lt;/p&gt;

&lt;p&gt;Think of it like leaving a breadcrumb.&lt;/p&gt;

&lt;p&gt;Before entering a new function, the program says:&lt;/p&gt;

&lt;p&gt;“Let me save where I came from, so I can restore it later.”&lt;/p&gt;

&lt;p&gt;When the function ends, the old base pointer is loaded back.&lt;/p&gt;

&lt;p&gt;Now the caller’s stack frame becomes active again.&lt;/p&gt;




&lt;h2&gt;
  
  
  How &lt;code&gt;add()&lt;/code&gt; Finds &lt;code&gt;x&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, and &lt;code&gt;result&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Inside &lt;code&gt;add()&lt;/code&gt;, we have this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CPU does not understand variable names like humans do.&lt;/p&gt;

&lt;p&gt;It does not think:&lt;/p&gt;

&lt;p&gt;“Oh, &lt;code&gt;x&lt;/code&gt; means 10 and &lt;code&gt;y&lt;/code&gt; means 4.”&lt;/p&gt;

&lt;p&gt;Instead, the compiler maps variables to memory locations.&lt;/p&gt;

&lt;p&gt;Using the base pointer, the program can find values by offsets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BP + 8   -&amp;gt; x
BP + 12  -&amp;gt; y
BP - 4   -&amp;gt; result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So when the function needs &lt;code&gt;x&lt;/code&gt;, it looks at something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BP + 8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When it needs &lt;code&gt;y&lt;/code&gt;, it looks at:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BP + 12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When it needs to store &lt;code&gt;result&lt;/code&gt;, it may use:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;So the line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;becomes something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;read value at BP + 8
read value at BP + 12
add them
store the answer at BP - 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = 10
y = 4

result = 14
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Returning Back to &lt;code&gt;main()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Now &lt;code&gt;add()&lt;/code&gt; reaches this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function returns &lt;code&gt;14&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then the &lt;code&gt;add()&lt;/code&gt; stack frame is no longer needed.&lt;/p&gt;

&lt;p&gt;So the program removes it from the stack.&lt;/p&gt;

&lt;p&gt;The stack pointer moves back.&lt;/p&gt;

&lt;p&gt;The old base pointer is restored.&lt;/p&gt;

&lt;p&gt;The return address tells the CPU where to continue.&lt;/p&gt;

&lt;p&gt;Now we are back inside &lt;code&gt;main()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The returned value &lt;code&gt;14&lt;/code&gt; is stored in &lt;code&gt;sum&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;14&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then this line runs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And we see:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  A Simple Visual Summary
&lt;/h2&gt;

&lt;p&gt;Here is a simplified version of what happens.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpwmu9ncbcxpw39kzjcxi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpwmu9ncbcxpw39kzjcxi.png" alt="Summary diagram" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before calling &lt;code&gt;add()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main stack frame
----------------
a = 10
sum = ?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While &lt;code&gt;add()&lt;/code&gt; is running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add stack frame
---------------
x = 10
y = 4
result = 14

main stack frame
----------------
a = 10
sum = ?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After &lt;code&gt;add()&lt;/code&gt; returns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main stack frame
----------------
a = 10
sum = 14
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then &lt;code&gt;main()&lt;/code&gt; prints:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  Does This Always Work Exactly Like This?
&lt;/h2&gt;

&lt;p&gt;Not always.&lt;/p&gt;

&lt;p&gt;This article uses a simplified model to make the concept easy to understand.&lt;/p&gt;

&lt;p&gt;Real systems can be more complex.&lt;/p&gt;

&lt;p&gt;Modern compilers may optimize away the base pointer.&lt;/p&gt;

&lt;p&gt;Function arguments may be passed through registers instead of the stack.&lt;/p&gt;

&lt;p&gt;Go uses goroutine stacks, which can grow and move.&lt;/p&gt;

&lt;p&gt;The exact stack layout depends on architecture, compiler version, and calling convention.&lt;/p&gt;

&lt;p&gt;But the core idea is still useful:&lt;/p&gt;

&lt;p&gt;Functions need stack frames.&lt;/p&gt;

&lt;p&gt;The stack pointer tracks the top of the stack.&lt;/p&gt;

&lt;p&gt;The base pointer gives a stable reference point inside a function frame.&lt;/p&gt;

&lt;p&gt;Return addresses help the program continue from the correct place.&lt;/p&gt;

&lt;p&gt;Old base pointers help restore the caller’s frame.&lt;/p&gt;

&lt;p&gt;Once you understand this model, debugging, assembly, recursion, memory layout, and low-level programming all become much less mysterious.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Real-Life Way to Remember It
&lt;/h2&gt;

&lt;p&gt;Imagine you are reading a book and solving exercises.&lt;/p&gt;

&lt;p&gt;You are on Chapter 5.&lt;/p&gt;

&lt;p&gt;Suddenly, Chapter 5 says:&lt;/p&gt;

&lt;p&gt;“Before continuing, go solve Example 2 from Chapter 3.”&lt;/p&gt;

&lt;p&gt;So you place a bookmark in Chapter 5.&lt;/p&gt;

&lt;p&gt;Then you go to Chapter 3 and solve the example.&lt;/p&gt;

&lt;p&gt;After finishing, you return to the bookmark in Chapter 5.&lt;/p&gt;

&lt;p&gt;In this story:&lt;/p&gt;

&lt;p&gt;The bookmark is like the return address.&lt;/p&gt;

&lt;p&gt;Your current page position is like the stack pointer.&lt;/p&gt;

&lt;p&gt;The start of your current exercise notes is like the base pointer.&lt;/p&gt;

&lt;p&gt;The notes for each exercise are like stack frames.&lt;/p&gt;

&lt;p&gt;Every function call is like temporarily jumping into another task, while carefully remembering how to come back.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>computerscience</category>
      <category>go</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Connect a Namecheap Domain to a DigitalOcean Droplet with Nginx</title>
      <dc:creator>Tahsin Abrar</dc:creator>
      <pubDate>Sat, 16 May 2026 15:31:38 +0000</pubDate>
      <link>https://forem.com/tahsin000/how-to-connect-a-namecheap-domain-to-a-digitalocean-droplet-with-nginx-2mok</link>
      <guid>https://forem.com/tahsin000/how-to-connect-a-namecheap-domain-to-a-digitalocean-droplet-with-nginx-2mok</guid>
      <description>&lt;p&gt;Buying a domain is exciting. Creating a server is exciting too.&lt;/p&gt;

&lt;p&gt;But the moment you try to connect both of them, things can feel confusing.&lt;/p&gt;

&lt;p&gt;You bought your domain from &lt;strong&gt;Namecheap&lt;/strong&gt;. You created a VPS on &lt;strong&gt;DigitalOcean&lt;/strong&gt;. Now you expect your website to open when someone visits your domain.&lt;/p&gt;

&lt;p&gt;But unlike shared hosting or cPanel hosting, DigitalOcean does not automatically connect everything for you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4c46znoecoi4anxk5frl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4c46znoecoi4anxk5frl.png" alt="diagram" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You need to set up two important things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;DNS&lt;/strong&gt; : so your domain points to your server&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nginx&lt;/strong&gt; : so your server knows how to serve your website&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this guide, we will walk through the full setup in a simple and beginner-friendly way.&lt;/p&gt;

&lt;p&gt;By the end, your domain will point to your DigitalOcean Droplet, Nginx will serve your website, and HTTPS will be enabled.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Big Picture
&lt;/h2&gt;

&lt;p&gt;Before touching any settings, let’s understand the flow.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Namecheap Domain
        ↓
DNS points to DigitalOcean IP
        ↓
DigitalOcean Droplet
        ↓
Nginx Web Server
        ↓
Your Website
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your domain is like a human-friendly address.&lt;/p&gt;

&lt;p&gt;Your DigitalOcean Droplet is the actual server.&lt;/p&gt;

&lt;p&gt;DNS connects the domain to the server.&lt;/p&gt;

&lt;p&gt;Nginx receives the request and serves your website files or forwards traffic to your app.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Create a DigitalOcean Droplet
&lt;/h2&gt;

&lt;p&gt;First, create a Droplet on DigitalOcean.&lt;/p&gt;

&lt;p&gt;For a beginner project or test website, this setup is usually enough:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ubuntu 22.04 LTS
Basic Droplet
1 GB RAM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the Droplet is created, DigitalOcean will give you a public IP address.&lt;/p&gt;

&lt;p&gt;It will look something like this:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Keep this IP address safe. You will need it in the next step.&lt;/p&gt;

&lt;p&gt;This IP is where your domain will point.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 2: Point Your Namecheap Domain to DigitalOcean
&lt;/h2&gt;

&lt;p&gt;Now go to your Namecheap account.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Domain List
→ Manage
→ Advanced DNS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are two common ways to connect your domain.&lt;/p&gt;




&lt;h2&gt;
  
  
  Option A: Use A Records
&lt;/h2&gt;

&lt;p&gt;This is the easiest method for beginners.&lt;/p&gt;

&lt;p&gt;Add these DNS records:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Host&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A Record&lt;/td&gt;
&lt;td&gt;@&lt;/td&gt;
&lt;td&gt;Your DigitalOcean IP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A Record&lt;/td&gt;
&lt;td&gt;www&lt;/td&gt;
&lt;td&gt;Your DigitalOcean IP&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

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

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Host&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A Record&lt;/td&gt;
&lt;td&gt;@&lt;/td&gt;
&lt;td&gt;159.89.xxx.xxx&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A Record&lt;/td&gt;
&lt;td&gt;www&lt;/td&gt;
&lt;td&gt;159.89.xxx.xxx&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You can keep TTL as the default value.&lt;/p&gt;

&lt;p&gt;Here is what this does:&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       → DigitalOcean server
www.example.com   → DigitalOcean server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So both the root domain and the &lt;code&gt;www&lt;/code&gt; version will go to the same Droplet.&lt;/p&gt;

&lt;p&gt;For most simple projects, this is the best starting point.&lt;/p&gt;




&lt;h2&gt;
  
  
  Option B: Use DigitalOcean Nameservers
&lt;/h2&gt;

&lt;p&gt;Another option is to manage DNS from DigitalOcean instead of Namecheap.&lt;/p&gt;

&lt;p&gt;In DigitalOcean, go to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Networking
→ Domains
→ Add Domain
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add your domain there.&lt;/p&gt;

&lt;p&gt;DigitalOcean will give you nameservers like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ns1.digitalocean.com
ns2.digitalocean.com
ns3.digitalocean.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then go back to Namecheap:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Domain
→ Manage
→ Nameservers
→ Custom DNS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add those three DigitalOcean nameservers and save.&lt;/p&gt;

&lt;p&gt;This method is useful when you want to manage all DNS records from DigitalOcean, especially if you have multiple subdomains or services.&lt;/p&gt;




&lt;h2&gt;
  
  
  Which DNS Method Should You Choose?
&lt;/h2&gt;

&lt;p&gt;For beginners, use &lt;strong&gt;A Records&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is simple, clear, and easy to debug.&lt;/p&gt;

&lt;p&gt;Use DigitalOcean nameservers when your setup becomes larger, 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;api.example.com
app.example.com
blog.example.com
admin.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For now, we will continue with the beginner-friendly A Record method.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3: Wait for DNS Propagation
&lt;/h2&gt;

&lt;p&gt;DNS changes are not always instant.&lt;/p&gt;

&lt;p&gt;Sometimes they work in a few minutes. Sometimes they take longer.&lt;/p&gt;

&lt;p&gt;Usually, it can take:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5 minutes to 1 hour
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In some cases, it may take up to:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;You can use tools like DNS Checker to see whether your domain is pointing to the correct server IP.&lt;/p&gt;

&lt;p&gt;A common beginner mistake is changing DNS and immediately thinking something is broken. Sometimes nothing is broken. DNS just needs a little time.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 4: Connect to Your Server with SSH
&lt;/h2&gt;

&lt;p&gt;Now connect to your DigitalOcean Droplet.&lt;/p&gt;

&lt;p&gt;On Mac or Linux, open your terminal.&lt;/p&gt;

&lt;p&gt;On Windows, you can use PowerShell or PuTTY.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh root@YOUR_SERVER_IP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh root@159.89.xxx.xxx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first time you connect, your terminal may ask for confirmation. Type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then enter your password or use your SSH key, depending on how you created the Droplet.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 5: Install Nginx
&lt;/h2&gt;

&lt;p&gt;Once you are inside the server, update the package list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then install Nginx:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;nginx &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check if Nginx 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;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything is working, you should see that Nginx is active.&lt;/p&gt;

&lt;p&gt;At this point, if you open your server IP in the browser, you may see the default Nginx welcome page.&lt;/p&gt;

&lt;p&gt;That means your web server is working.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 6: Configure the Firewall
&lt;/h2&gt;

&lt;p&gt;Ubuntu servers often use &lt;code&gt;ufw&lt;/code&gt; for firewall management.&lt;/p&gt;

&lt;p&gt;Allow Nginx traffic:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow &lt;span class="s1"&gt;'Nginx Full'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also allow SSH so you do not lock yourself out:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow OpenSSH
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then enable the firewall:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw &lt;span class="nb"&gt;enable&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can check the firewall status with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see that HTTP, HTTPS, and SSH traffic are allowed.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 7: Create a Website Folder
&lt;/h2&gt;

&lt;p&gt;Now create a folder for your website.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /var/www/myproject
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a test HTML file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /var/www/myproject/index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paste this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Hello from DigitalOcean&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CTRL + X
Y
Enter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This simple file will help us confirm that the domain and Nginx setup are working.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 8: Create an Nginx Server Block
&lt;/h2&gt;

&lt;p&gt;An Nginx server block tells Nginx how to handle traffic for a specific domain.&lt;/p&gt;

&lt;p&gt;Create a new config file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/nginx/sites-available/myproject
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paste this configuration:&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="k"&gt;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&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="kn"&gt;server_name&lt;/span&gt; &lt;span class="s"&gt;example.com&lt;/span&gt; &lt;span class="s"&gt;www.example.com&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;root&lt;/span&gt; &lt;span class="n"&gt;/var/www/myproject&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;index&lt;/span&gt; &lt;span class="s"&gt;index.html&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="n"&gt;/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kn"&gt;try_files&lt;/span&gt; &lt;span class="nv"&gt;$uri&lt;/span&gt; &lt;span class="nv"&gt;$uri&lt;/span&gt;&lt;span class="n"&gt;/&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&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;Replace this:&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="k"&gt;example.com&lt;/span&gt; &lt;span class="s"&gt;www.example.com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With your real 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 nginx"&gt;&lt;code&gt;&lt;span class="k"&gt;server_name&lt;/span&gt; &lt;span class="s"&gt;mycoolsite.com&lt;/span&gt; &lt;span class="s"&gt;www.mycoolsite.com&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This config says:&lt;/p&gt;

&lt;p&gt;“When someone visits this domain, serve files from &lt;code&gt;/var/www/myproject&lt;/code&gt;.”&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 9: Enable the Site
&lt;/h2&gt;

&lt;p&gt;Nginx keeps available site configs in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/etc/nginx/sites-available/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But it only uses configs that are linked in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/etc/nginx/sites-enabled/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So we need to enable the site:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo ln&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; /etc/nginx/sites-available/myproject /etc/nginx/sites-enabled/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 10: Test and Reload Nginx
&lt;/h2&gt;

&lt;p&gt;Before restarting Nginx, always test the config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nginx &lt;span class="nt"&gt;-t&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything is fine, you should see something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;syntax is ok
test is successful
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now reload Nginx:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl reload nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open your domain in the browser:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello from DigitalOcean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Great. Your domain is now connected to your Droplet.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 11: Add HTTPS with Certbot
&lt;/h2&gt;

&lt;p&gt;A production website should use HTTPS.&lt;/p&gt;

&lt;p&gt;For that, we can use Certbot with Let’s Encrypt.&lt;/p&gt;

&lt;p&gt;Install Certbot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;certbot python3-certbot-nginx &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;certbot &lt;span class="nt"&gt;--nginx&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Certbot will ask you to choose the domain.&lt;/p&gt;

&lt;p&gt;Select your domain and allow redirect to HTTPS.&lt;/p&gt;

&lt;p&gt;After that, your site should work with:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Certbot also sets up automatic renewal, so your SSL certificate can renew before it expires.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Architecture
&lt;/h2&gt;

&lt;p&gt;Your setup now looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Namecheap
   ↓
DNS A Record
   ↓
DigitalOcean Droplet IP
   ↓
Nginx
   ↓
Website Files
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a common real-world setup used by many developers.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Feels Different from cPanel Hosting
&lt;/h2&gt;

&lt;p&gt;If you are coming from cPanel hosting, DigitalOcean may feel harder at first.&lt;/p&gt;

&lt;p&gt;That is normal.&lt;/p&gt;

&lt;p&gt;With cPanel hosting, the hosting company usually handles many things for you:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DNS
Apache or Nginx
SSL
PHP
File manager
Email tools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You often just change nameservers and upload your files.&lt;/p&gt;

&lt;p&gt;But with a DigitalOcean VPS, you manage the server yourself.&lt;/p&gt;

&lt;p&gt;That means you are responsible for:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Nginx
Firewall
SSL
App runtime
Deployment
Security
Logs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The benefit is flexibility.&lt;/p&gt;

&lt;p&gt;You can run Node.js, Laravel, Docker, PostgreSQL, Redis, background workers, multiple apps, and more.&lt;/p&gt;

&lt;p&gt;The tradeoff is that you need to understand the server setup.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Real-Life Example
&lt;/h2&gt;

&lt;p&gt;Imagine you built a small portfolio website.&lt;/p&gt;

&lt;p&gt;You bought:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;from Namecheap.&lt;/p&gt;

&lt;p&gt;Then you created a DigitalOcean Droplet with this IP:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;In Namecheap, you add:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Host&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A Record&lt;/td&gt;
&lt;td&gt;@&lt;/td&gt;
&lt;td&gt;159.89.100.50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A Record&lt;/td&gt;
&lt;td&gt;www&lt;/td&gt;
&lt;td&gt;159.89.100.50&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Then on your server, your Nginx config looks like this:&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="k"&gt;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&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="kn"&gt;server_name&lt;/span&gt; &lt;span class="s"&gt;myportfolio.com&lt;/span&gt; &lt;span class="s"&gt;www.myportfolio.com&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;root&lt;/span&gt; &lt;span class="n"&gt;/var/www/myportfolio&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;index&lt;/span&gt; &lt;span class="s"&gt;index.html&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="n"&gt;/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kn"&gt;try_files&lt;/span&gt; &lt;span class="nv"&gt;$uri&lt;/span&gt; &lt;span class="nv"&gt;$uri&lt;/span&gt;&lt;span class="n"&gt;/&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&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;After reloading Nginx and setting up SSL, visitors can open:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;And see your website.&lt;/p&gt;

&lt;p&gt;That is the full journey from domain to live website.&lt;/p&gt;

</description>
      <category>nginx</category>
      <category>dohackathon</category>
      <category>dns</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Hubs, Switches, and Routers Explained Like You're Debugging a Real Network</title>
      <dc:creator>Tahsin Abrar</dc:creator>
      <pubDate>Mon, 11 May 2026 06:48:03 +0000</pubDate>
      <link>https://forem.com/tahsin000/hubs-switches-and-routers-explained-like-youre-debugging-a-real-network-4co5</link>
      <guid>https://forem.com/tahsin000/hubs-switches-and-routers-explained-like-youre-debugging-a-real-network-4co5</guid>
      <description>&lt;p&gt;Have you ever connected your laptop to Wi-Fi, opened a browser, typed a URL, and wondered:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How does my message actually reach the right computer?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxkd0w9umlrmvboqt9mif.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxkd0w9umlrmvboqt9mif.png" alt="Diagram" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As developers, we often work with APIs, servers, ports, IP addresses, localhost, Docker networks, cloud servers, and routers. But networking can feel confusing because many explanations jump straight into heavy terms.&lt;/p&gt;

&lt;p&gt;So let's slow down and make it simple.&lt;/p&gt;

&lt;p&gt;In this post, we'll understand three important network devices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Hub&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Switch&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Router&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We'll also see how data moves from one computer to another inside a local network, and how your computer decides whether to send data directly to another device or through the router.&lt;/p&gt;

&lt;p&gt;This article is based on the provided networking class transcript about hubs, switches, routers, MAC tables, and internal communication. &lt;/p&gt;




&lt;h2&gt;
  
  
  First, Imagine a Small Room Full of Computers
&lt;/h2&gt;

&lt;p&gt;Imagine five computers connected in the same room.&lt;/p&gt;

&lt;p&gt;One computer wants to send a message to another computer.&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;Computer A wants to send data to Computer D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That sounds simple. But the network has to answer some important questions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Who sent the data?
Who should receive it?
Are both devices in the same network?
Should the data go to another device first?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is where hubs, switches, and routers come in.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Hub: The Loud but Not-So-Smart Device
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;hub&lt;/strong&gt; is one of the simplest network devices.&lt;/p&gt;

&lt;p&gt;You can think of it like a loudspeaker.&lt;/p&gt;

&lt;p&gt;When one computer sends data to a hub, the hub does not check who the data is for. It simply forwards the data to every other connected port.&lt;/p&gt;

&lt;p&gt;So if Computer A sends data through a hub, the hub sends it to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Computer B
Computer C
Computer D
Computer E
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even if the message was only meant for Computer D.&lt;/p&gt;

&lt;p&gt;The other computers receive the data, check it, and then ignore it if it is not meant for them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is a hub considered "not smart"?
&lt;/h3&gt;

&lt;p&gt;Because a hub works at the &lt;strong&gt;physical layer&lt;/strong&gt;, also called &lt;strong&gt;Layer 1&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It only understands electrical signals or bits.&lt;/p&gt;

&lt;p&gt;It does not understand:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MAC addresses
IP addresses
Ports
Applications
Actual message content
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So a hub cannot make smart forwarding decisions.&lt;/p&gt;

&lt;p&gt;It just repeats the signal.&lt;/p&gt;

&lt;h3&gt;
  
  
  Simple way to remember a hub
&lt;/h3&gt;

&lt;p&gt;A hub says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I don't know who needs this, so I'll send it to everyone."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is why hubs are rarely used in modern networks.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Switch: A Smarter Device That Learns
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;switch&lt;/strong&gt; is much smarter than a hub.&lt;/p&gt;

&lt;p&gt;A switch works at the &lt;strong&gt;data link layer&lt;/strong&gt;, also called &lt;strong&gt;Layer 2&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That means a switch can understand &lt;strong&gt;MAC addresses&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A MAC address is like the hardware address of a network device. Every network interface has one.&lt;/p&gt;

&lt;p&gt;For example, imagine five devices connected to a switch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Port 1 -&amp;gt; Computer A
Port 2 -&amp;gt; Computer B
Port 3 -&amp;gt; Computer C
Port 4 -&amp;gt; Computer D
Port 5 -&amp;gt; Computer E
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each computer has a MAC address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Computer A -&amp;gt; MAC A
Computer B -&amp;gt; MAC B
Computer C -&amp;gt; MAC C
Computer D -&amp;gt; MAC D
Computer E -&amp;gt; MAC E
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now Computer A wants to send data to Computer D.&lt;/p&gt;

&lt;p&gt;The Ethernet frame may look like this in a simplified way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source MAC: A
Destination MAC: D
Data: Hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the switch receives this frame, it checks the &lt;strong&gt;source MAC address&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It says:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MAC A came from Port 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then it saves that information in a table.&lt;/p&gt;

&lt;p&gt;This table is commonly called:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MAC address table
CAM table
Forwarding database
Bridge table
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Different books and vendors may use different names, but the idea is the same.&lt;/p&gt;

&lt;p&gt;The switch keeps a record like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MAC Address    Port
A              1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  What Happens When the Switch Does Not Know the Destination?
&lt;/h2&gt;

&lt;p&gt;Now the switch checks the destination MAC address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Destination MAC: D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But imagine this is the first time the switch has seen Computer D.&lt;/p&gt;

&lt;p&gt;So the switch does not yet know which port leads to MAC D.&lt;/p&gt;

&lt;p&gt;What does it do?&lt;/p&gt;

&lt;p&gt;It &lt;strong&gt;floods&lt;/strong&gt; the frame.&lt;/p&gt;

&lt;p&gt;That means it sends the frame to every port except the port it came from.&lt;/p&gt;

&lt;p&gt;So the frame goes to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Port 2
Port 3
Port 4
Port 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Computer B receives it and says:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This is not for me.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Computer C says the same.&lt;/p&gt;

&lt;p&gt;Computer E says the same.&lt;/p&gt;

&lt;p&gt;But Computer D checks the destination MAC and says:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This is mine.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So Computer D accepts the frame.&lt;/p&gt;




&lt;h2&gt;
  
  
  How the Switch Learns Over Time
&lt;/h2&gt;

&lt;p&gt;Now Computer D replies to Computer A.&lt;/p&gt;

&lt;p&gt;The reply frame looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source MAC: D
Destination MAC: A
Data: Hello back
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The switch receives the frame from Port 4.&lt;/p&gt;

&lt;p&gt;It checks the source MAC address and learns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MAC D came from Port 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the switch table becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MAC Address    Port
A              1
D              4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next time Computer A sends data to Computer D, the switch does not need to flood the frame.&lt;/p&gt;

&lt;p&gt;It already knows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MAC D is on Port 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So it sends the frame only to Port 4.&lt;/p&gt;

&lt;p&gt;That is why a switch is more efficient than a hub.&lt;/p&gt;

&lt;h3&gt;
  
  
  Simple way to remember a switch
&lt;/h3&gt;

&lt;p&gt;A switch says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I’ll learn where devices are, then send data only where it needs to go."&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Hub vs Switch in One Simple Example
&lt;/h2&gt;

&lt;p&gt;Imagine a classroom.&lt;/p&gt;

&lt;p&gt;A hub is like a student who receives a note and shouts it to the whole class.&lt;/p&gt;

&lt;p&gt;A switch is like a helpful class monitor who learns where everyone sits and quietly gives the note to the right person.&lt;/p&gt;

&lt;p&gt;That is the main difference.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where Does the Router Fit In?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;router&lt;/strong&gt; works at the &lt;strong&gt;network layer&lt;/strong&gt;, also called &lt;strong&gt;Layer 3&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That means a router understands &lt;strong&gt;IP addresses&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A switch mainly cares about MAC addresses inside a local network.&lt;/p&gt;

&lt;p&gt;A router cares about moving data between different networks.&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;Your laptop -&amp;gt; your home network
Your home network -&amp;gt; the internet
The internet -&amp;gt; another server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The router is the device that connects your local network to other networks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Simple way to remember a router
&lt;/h3&gt;

&lt;p&gt;A router says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"This data needs to go outside this network. I know where to send it next."&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Your Home Router Is Usually More Than Just a Router
&lt;/h2&gt;

&lt;p&gt;This part is important.&lt;/p&gt;

&lt;p&gt;The device we casually call a "router" at home is usually not just a router.&lt;/p&gt;

&lt;p&gt;It often contains multiple things inside one box:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Router
Switch
Wi-Fi access point
DHCP server
Firewall/NAT features
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So when you plug an Ethernet cable into your home router, you are usually plugging it into the &lt;strong&gt;switch part&lt;/strong&gt; of the device.&lt;/p&gt;

&lt;p&gt;When your laptop connects through Wi-Fi, it connects through the wireless access point part.&lt;/p&gt;

&lt;p&gt;The real routing happens when data needs to leave your local network and go somewhere else, like the internet.&lt;/p&gt;




&lt;h2&gt;
  
  
  LAN Interface and WAN Interface
&lt;/h2&gt;

&lt;p&gt;A home router usually has two sides:&lt;/p&gt;

&lt;h3&gt;
  
  
  LAN side
&lt;/h3&gt;

&lt;p&gt;This is your local network.&lt;/p&gt;

&lt;p&gt;Your laptop, phone, printer, TV, and other home devices live here.&lt;/p&gt;

&lt;p&gt;Example local IP addresses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;192.168.1.10
192.168.1.11
192.168.1.12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your router may have a local IP like:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This is often called the &lt;strong&gt;default gateway&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  WAN side
&lt;/h3&gt;

&lt;p&gt;This is the side connected to your internet provider.&lt;/p&gt;

&lt;p&gt;The router gets a public or provider-side IP address on this side.&lt;/p&gt;

&lt;p&gt;So your router sits between:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your private home network
The outside internet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  How Does a Computer Decide Where to Send Data?
&lt;/h2&gt;

&lt;p&gt;Now comes a very important question.&lt;/p&gt;

&lt;p&gt;Suppose your computer wants to send data to another IP address.&lt;/p&gt;

&lt;p&gt;How does it know whether the destination is inside the same local network or outside?&lt;/p&gt;

&lt;p&gt;It uses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Its own IP address
The destination IP address
The subnet mask
The default gateway
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Usually, your computer gets these from DHCP.&lt;/p&gt;

&lt;p&gt;A DHCP server may give your device:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IP address:       192.168.1.10
Subnet mask:      255.255.255.0
Default gateway:  192.168.1.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your computer can make a decision.&lt;/p&gt;




&lt;h2&gt;
  
  
  Example 1: Sending Data Inside the Same Network
&lt;/h2&gt;

&lt;p&gt;Let's say:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Computer A IP: 192.168.1.10
Computer C IP: 192.168.1.11
Subnet mask:   255.255.255.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Computer A wants to send data to Computer C.&lt;/p&gt;

&lt;p&gt;It checks whether both IP addresses belong to the same network.&lt;/p&gt;

&lt;p&gt;With this subnet mask, both addresses are part of:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;So Computer A understands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Computer C is in my local network.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That means Computer A does not need to send the data to the router for routing.&lt;/p&gt;

&lt;p&gt;Instead, it sends an Ethernet frame directly toward Computer C's MAC address.&lt;/p&gt;

&lt;p&gt;Simplified frame:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source MAC: A
Destination MAC: C
Source IP: 192.168.1.10
Destination IP: 192.168.1.11
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The switch receives the frame and forwards it to Computer C.&lt;/p&gt;

&lt;p&gt;The router part does not need to be involved.&lt;/p&gt;




&lt;h2&gt;
  
  
  Example 2: Sending Data Outside the Network
&lt;/h2&gt;

&lt;p&gt;Now imagine Computer A wants to send data to:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;That IP is not inside the local network &lt;code&gt;192.168.1.0/24&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So Computer A understands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This destination is outside my network.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now something interesting happens.&lt;/p&gt;

&lt;p&gt;The destination IP stays as:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;But the destination MAC address becomes the MAC address of the router.&lt;/p&gt;

&lt;p&gt;Simplified frame:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source MAC: A
Destination MAC: Router
Source IP: 192.168.1.10
Destination IP: 8.8.8.8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because inside the local network, the computer can only deliver frames to local devices by MAC address.&lt;/p&gt;

&lt;p&gt;To reach the outside world, it sends the frame to the default gateway first.&lt;/p&gt;

&lt;p&gt;The router receives it, looks at the destination IP, and then decides where to send it next.&lt;/p&gt;




&lt;h2&gt;
  
  
  Important Detail: MAC Address Changes, IP Address Stays
&lt;/h2&gt;

&lt;p&gt;This is one of the most useful networking ideas to understand.&lt;/p&gt;

&lt;p&gt;When data moves across networks, the IP packet is trying to reach the final IP address.&lt;/p&gt;

&lt;p&gt;But at each local network hop, the MAC address may change.&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;Your laptop -&amp;gt; Router
Router -&amp;gt; ISP device
ISP device -&amp;gt; next router
Next router -&amp;gt; destination server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each step may use a different source and destination MAC address.&lt;/p&gt;

&lt;p&gt;But the destination IP is still the final server's IP.&lt;/p&gt;

&lt;p&gt;That is why:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Switches care about MAC addresses.
Routers care about IP addresses.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  A Developer-Friendly Example
&lt;/h2&gt;

&lt;p&gt;Imagine you are building a backend API.&lt;/p&gt;

&lt;p&gt;Your laptop is running a frontend app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:5173
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another computer on the same Wi-Fi is running an API server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://192.168.1.25:3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When your laptop calls that API, it checks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Am I in the same network as 192.168.1.25?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If yes, your laptop sends the frame toward that device's MAC address.&lt;/p&gt;

&lt;p&gt;The switch or Wi-Fi access point handles local delivery.&lt;/p&gt;

&lt;p&gt;The router does not need to send the traffic to the internet.&lt;/p&gt;

&lt;p&gt;Now imagine your app calls:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;That server is outside your local network.&lt;/p&gt;

&lt;p&gt;So your laptop sends the frame to the router's MAC address.&lt;/p&gt;

&lt;p&gt;The router then forwards the packet toward the internet.&lt;/p&gt;

&lt;p&gt;This is happening all the time while you code.&lt;/p&gt;




&lt;h2&gt;
  
  
  Quick Comparison: Hub vs Switch vs Router
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Device&lt;/th&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Understands&lt;/th&gt;
&lt;th&gt;Main Job&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hub&lt;/td&gt;
&lt;td&gt;Layer 1&lt;/td&gt;
&lt;td&gt;Bits/signals&lt;/td&gt;
&lt;td&gt;Sends data to all ports&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Switch&lt;/td&gt;
&lt;td&gt;Layer 2&lt;/td&gt;
&lt;td&gt;MAC addresses&lt;/td&gt;
&lt;td&gt;Sends frames inside a local network&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Router&lt;/td&gt;
&lt;td&gt;Layer 3&lt;/td&gt;
&lt;td&gt;IP addresses&lt;/td&gt;
&lt;td&gt;Sends packets between networks&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Common Terms You Should Remember
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Frame
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;frame&lt;/strong&gt; belongs to the data link layer.&lt;/p&gt;

&lt;p&gt;It contains MAC address information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source MAC
Destination MAC
Payload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Packet
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;packet&lt;/strong&gt; belongs to the network layer.&lt;/p&gt;

&lt;p&gt;It contains IP address information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source IP
Destination IP
Payload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Segment
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;segment&lt;/strong&gt; usually belongs to TCP at the transport layer.&lt;/p&gt;

&lt;p&gt;It contains port information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source port
Destination port
Data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  MAC address table
&lt;/h3&gt;

&lt;p&gt;A switch uses this table to remember which MAC address is connected to which port.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MAC Address    Port
A              1
C              3
D              4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Default gateway
&lt;/h3&gt;

&lt;p&gt;The default gateway is usually your router's local IP address.&lt;/p&gt;

&lt;p&gt;Your computer sends data to the default gateway when the destination is outside the local network.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Simple Mental Model
&lt;/h2&gt;

&lt;p&gt;Here is the easiest way to remember everything:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hub:
"I will send it to everyone."

Switch:
"I will send it to the correct local device if I know where it is."

Router:
"I will send it to another network."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it.&lt;/p&gt;

&lt;p&gt;Once you understand this, many networking topics become easier:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DHCP
ARP
Subnetting
NAT
Docker networking
Kubernetes networking
Cloud VPCs
Firewalls
Load balancers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>networking</category>
      <category>beginners</category>
      <category>computerscience</category>
      <category>webdev</category>
    </item>
    <item>
      <title>DNS Made Simple: What Really Happens Before Your Browser Opens a Website</title>
      <dc:creator>Tahsin Abrar</dc:creator>
      <pubDate>Thu, 23 Apr 2026 16:25:15 +0000</pubDate>
      <link>https://forem.com/tahsin000/dns-made-simple-what-really-happens-before-your-browser-opens-a-website-2281</link>
      <guid>https://forem.com/tahsin000/dns-made-simple-what-really-happens-before-your-browser-opens-a-website-2281</guid>
      <description>&lt;p&gt;We use domain names every day.&lt;/p&gt;

&lt;p&gt;We type &lt;code&gt;google.com&lt;/code&gt;, &lt;code&gt;facebook.com&lt;/code&gt;, or &lt;code&gt;linkedin.com&lt;/code&gt; into a browser, press Enter, and the website opens in seconds. It feels simple. Almost boring.&lt;/p&gt;

&lt;p&gt;But under the hood, something very important happens before your browser can even start talking to that website.&lt;/p&gt;

&lt;p&gt;That thing is &lt;strong&gt;DNS&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And here is the part many developers miss early on: if you want to understand &lt;strong&gt;TLS/SSL&lt;/strong&gt;, networking, deployment, or even why a request is slow, you need to understand DNS first.&lt;/p&gt;

&lt;p&gt;Because before secure communication begins, your browser has to answer one basic question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Where is this website actually hosted?”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's break it down in the simplest possible way.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnc27hy9g7ncv0a7f3on1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnc27hy9g7ncv0a7f3on1.png" alt=" " width="800" height="771"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  First, let's understand the URL
&lt;/h2&gt;

&lt;p&gt;Take this URL:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;It has a few parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;https&lt;/code&gt; → the scheme or protocol&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;blog&lt;/code&gt; → the subdomain&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;example&lt;/code&gt; → the main domain&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.com&lt;/code&gt; → the top-level domain (TLD)&lt;/li&gt;
&lt;/ul&gt;

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

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

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;https&lt;/code&gt; is the protocol&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;engineering&lt;/code&gt; is the subdomain&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;linkedin&lt;/code&gt; is the domain&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.com&lt;/code&gt; is the TLD&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This structure matters because DNS works with these names.&lt;/p&gt;

&lt;p&gt;Before we go into DNS, we need to understand one thing clearly:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a domain name is not the real machine address.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is the human-friendly name for that machine.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why domain names exist
&lt;/h2&gt;

&lt;p&gt;Humans are good at remembering words.&lt;/p&gt;

&lt;p&gt;Machines are good at working with numbers.&lt;/p&gt;

&lt;p&gt;That is the heart of the whole idea.&lt;/p&gt;

&lt;p&gt;You can easily remember:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;But remembering something like this is much harder:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;That number is an IP address.&lt;/p&gt;

&lt;p&gt;An IP address is the real network address of a machine or server.&lt;/p&gt;

&lt;p&gt;So when you type a domain name into a browser, your system has to find the IP address behind that name.&lt;/p&gt;

&lt;p&gt;That translation is what DNS does.&lt;/p&gt;




&lt;h2&gt;
  
  
  A simple real-life example
&lt;/h2&gt;

&lt;p&gt;Think about your home address.&lt;/p&gt;

&lt;p&gt;If someone knows your address, they can find your house.&lt;/p&gt;

&lt;p&gt;Computers work in a similar way.&lt;/p&gt;

&lt;p&gt;Every machine connected to a network needs an address. On the internet, that address is the &lt;strong&gt;IP address&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now imagine you built an app locally on your laptop. Maybe it runs on:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;That works on your own machine because your machine knows what &lt;code&gt;localhost&lt;/code&gt; means.&lt;/p&gt;

&lt;p&gt;But if you deploy that app to a server on AWS, DigitalOcean, or anywhere else, people cannot visit it using &lt;code&gt;localhost&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;They need the address of that server.&lt;/p&gt;

&lt;p&gt;That real address is the IP address.&lt;/p&gt;

&lt;p&gt;But asking users to remember IP addresses is a terrible experience.&lt;/p&gt;

&lt;p&gt;So instead of telling people:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;we give the server a domain name like:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Now people can remember the name, and machines can still connect using the IP.&lt;/p&gt;

&lt;p&gt;That mapping between a human-friendly name and a machine-friendly IP is the whole point of DNS.&lt;/p&gt;




&lt;h2&gt;
  
  
  So what is DNS?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;DNS stands for Domain Name System.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's keep it simple:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DNS is the system that converts a domain name into an IP address.&lt;/strong&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;You type &lt;code&gt;facebook.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;DNS finds the IP address behind &lt;code&gt;facebook.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Your browser uses that IP to contact the correct server&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is called a &lt;strong&gt;system&lt;/strong&gt; because it is not just one thing.&lt;/p&gt;

&lt;p&gt;It involves multiple parts working together:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;your browser&lt;/li&gt;
&lt;li&gt;your operating system&lt;/li&gt;
&lt;li&gt;DNS caches&lt;/li&gt;
&lt;li&gt;a DNS resolver&lt;/li&gt;
&lt;li&gt;root name servers&lt;/li&gt;
&lt;li&gt;TLD name servers&lt;/li&gt;
&lt;li&gt;authoritative name servers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is why it is not called just "domain name lookup.”&lt;/p&gt;

&lt;p&gt;It is a &lt;strong&gt;system&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Before DNS goes to the internet, it checks cache
&lt;/h2&gt;

&lt;p&gt;This is one of the most useful things to understand.&lt;/p&gt;

&lt;p&gt;When you visit a website, your computer does not always start from scratch.&lt;/p&gt;

&lt;p&gt;It first checks whether the answer is already stored somewhere.&lt;/p&gt;

&lt;p&gt;This stored answer is called &lt;strong&gt;cache&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Think of cache like a shortcut memory.&lt;/p&gt;

&lt;p&gt;If the system already knows the IP address for a domain, it can skip a lot of work.&lt;/p&gt;

&lt;p&gt;That makes everything faster.&lt;/p&gt;

&lt;p&gt;Usually, the lookup goes through these layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Browser cache&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Operating system cache&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;DNS resolver cache&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;If not found, then the full DNS lookup starts&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That is why websites often open very quickly the second time you visit them.&lt;/p&gt;




&lt;h2&gt;
  
  
  The full DNS journey, step by step
&lt;/h2&gt;

&lt;p&gt;Now let's walk through what actually happens when you type:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;into your browser.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The browser checks its own cache
&lt;/h3&gt;

&lt;p&gt;Your browser first asks:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Do I already know the IP for this domain?”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If yes, great. It uses that IP immediately.&lt;/p&gt;

&lt;p&gt;If not, it moves to the next step.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. The operating system checks its cache
&lt;/h3&gt;

&lt;p&gt;If the browser does not have the answer, your operating system checks whether it has that domain-to-IP mapping stored.&lt;/p&gt;

&lt;p&gt;If the OS already knows it, it returns the IP to the browser.&lt;/p&gt;

&lt;p&gt;If not, the request continues.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. The system asks a DNS resolver
&lt;/h3&gt;

&lt;p&gt;Now the request goes to a &lt;strong&gt;DNS resolver&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In many cases, this resolver belongs to your ISP, though it could also be a public DNS service.&lt;/p&gt;

&lt;p&gt;Its job is to find the answer for you.&lt;/p&gt;

&lt;p&gt;And just like the browser and OS, the resolver also checks its own cache first.&lt;/p&gt;

&lt;p&gt;If the resolver already knows the IP for &lt;code&gt;facebook.com&lt;/code&gt;, it returns it immediately.&lt;/p&gt;

&lt;p&gt;If not, now the real DNS lookup begins.&lt;/p&gt;




&lt;h2&gt;
  
  
  The resolver starts asking other DNS servers
&lt;/h2&gt;

&lt;p&gt;This is where many learners get confused, but the logic is actually very clean.&lt;/p&gt;

&lt;p&gt;The resolver does not magically know every IP address in the world.&lt;/p&gt;

&lt;p&gt;Instead, it asks the right servers in the right order.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. It asks a root name server
&lt;/h3&gt;

&lt;p&gt;The resolver asks a root name server something like:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"I need information about &lt;code&gt;.com&lt;/code&gt;. Where should I go next?”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Notice something important:&lt;/p&gt;

&lt;p&gt;It is &lt;strong&gt;not&lt;/strong&gt; asking for the final IP address yet.&lt;/p&gt;

&lt;p&gt;It is asking where the &lt;code&gt;.com&lt;/code&gt; information is managed.&lt;/p&gt;

&lt;p&gt;The root server replies with the address of the &lt;strong&gt;TLD name server&lt;/strong&gt; for &lt;code&gt;.com&lt;/code&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  5. It asks the TLD name server
&lt;/h3&gt;

&lt;p&gt;Now the resolver goes to the &lt;code&gt;.com&lt;/code&gt; TLD server and asks:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Who is responsible for &lt;code&gt;facebook.com&lt;/code&gt;?”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Again, this server usually does not return the final website IP directly.&lt;/p&gt;

&lt;p&gt;Instead, it returns the address of the &lt;strong&gt;authoritative name server&lt;/strong&gt; for that domain.&lt;/p&gt;

&lt;p&gt;That server is the source of truth for the domain's DNS records.&lt;/p&gt;




&lt;h3&gt;
  
  
  6. It asks the authoritative name server
&lt;/h3&gt;

&lt;p&gt;Now the resolver asks the authoritative name server:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"What is the IP address for &lt;code&gt;facebook.com&lt;/code&gt;?”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This server returns the actual DNS record, such as the IP address.&lt;/p&gt;

&lt;p&gt;Now the resolver finally has the answer it needs.&lt;/p&gt;




&lt;h3&gt;
  
  
  7. The answer comes back and gets cached
&lt;/h3&gt;

&lt;p&gt;Once the resolver gets the IP address, it does two useful things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;it returns the answer to your operating system&lt;/li&gt;
&lt;li&gt;it stores the answer in cache for future requests&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then the OS may cache it too.&lt;/p&gt;

&lt;p&gt;Then the browser may cache it too.&lt;/p&gt;

&lt;p&gt;That means the next lookup can be much faster.&lt;/p&gt;




&lt;h3&gt;
  
  
  8. The browser can finally contact the server
&lt;/h3&gt;

&lt;p&gt;Now your browser has the IP address.&lt;/p&gt;

&lt;p&gt;At this point, it can finally open a network connection to the actual server and send the real HTTP or HTTPS request.&lt;/p&gt;

&lt;p&gt;That is the moment when the website request truly begins.&lt;/p&gt;

&lt;p&gt;So yes, DNS happens &lt;strong&gt;before&lt;/strong&gt; the browser can talk to the web server.&lt;/p&gt;

&lt;p&gt;And that is exactly why DNS matters when learning TLS/SSL.&lt;/p&gt;




&lt;h2&gt;
  
  
  A simple mental model
&lt;/h2&gt;

&lt;p&gt;If all the server names sound too abstract, use this mental model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Root server&lt;/strong&gt; → "I do not know the full answer, but I know who handles &lt;code&gt;.com&lt;/code&gt;.”&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TLD server&lt;/strong&gt; → "I do not know the full answer, but I know who handles &lt;code&gt;facebook.com&lt;/code&gt;.”&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authoritative server&lt;/strong&gt; → "I am responsible for this domain. Here is the actual answer.”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is the chain.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why DNS is called "resolution”
&lt;/h2&gt;

&lt;p&gt;You may hear the phrase:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DNS resolution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This simply means:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;the process of resolving a domain name into an IP address&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So if someone says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The DNS resolution failed”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;they mean:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The system could not turn the domain name into an IP address”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;No IP, no connection.&lt;br&gt;
No connection, no website.&lt;/p&gt;


&lt;h2&gt;
  
  
  Where subdomains fit into this
&lt;/h2&gt;

&lt;p&gt;Let's say you have a domain like:&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;You can create subdomains like:&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
api.example.com
admin.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is useful because one domain can support multiple services.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;blog.example.com&lt;/code&gt; → blog website&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;api.example.com&lt;/code&gt; → backend API&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;admin.example.com&lt;/code&gt; → internal admin dashboard&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Same parent domain.&lt;br&gt;
Different subdomains.&lt;br&gt;
Different purposes.&lt;/p&gt;

&lt;p&gt;That is why learning domain structure matters before learning DNS deeply.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why websites feel fast after the first visit
&lt;/h2&gt;

&lt;p&gt;A lot of developers notice this but do not always connect it to DNS.&lt;/p&gt;

&lt;p&gt;The first request may take a bit longer because the system needs to find the IP.&lt;/p&gt;

&lt;p&gt;Later requests are faster because the answer may already exist in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;browser cache&lt;/li&gt;
&lt;li&gt;OS cache&lt;/li&gt;
&lt;li&gt;resolver cache&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That means the system can skip most of the lookup chain.&lt;/p&gt;

&lt;p&gt;So if a website opens instantly the second time, caching is often part of the reason.&lt;/p&gt;




&lt;h2&gt;
  
  
  Does DNS use TCP or UDP?
&lt;/h2&gt;

&lt;p&gt;In simple learning material, DNS is often explained with &lt;strong&gt;UDP&lt;/strong&gt;, and that is a good starting point.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because UDP is lightweight and fast. It does not need a full connection setup like TCP.&lt;/p&gt;

&lt;p&gt;For many standard DNS queries, that makes it a great fit.&lt;/p&gt;

&lt;p&gt;A simple way to think about it is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DNS wants to ask a quick question&lt;/li&gt;
&lt;li&gt;get a quick answer&lt;/li&gt;
&lt;li&gt;and move on&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That said, in real systems, DNS can also use TCP in some cases.&lt;/p&gt;

&lt;p&gt;But when you are first learning how DNS feels fast and lightweight, starting with UDP gives you the right intuition.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why DNS matters before TLS/SSL
&lt;/h2&gt;

&lt;p&gt;This is the part many people skip.&lt;/p&gt;

&lt;p&gt;They jump into HTTPS, SSL certificates, and TLS handshakes without asking a more basic question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How did the browser even find the server in the first place?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before secure communication starts, the browser needs to know where to connect.&lt;/p&gt;

&lt;p&gt;That means:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;resolve the domain name into an IP address&lt;/li&gt;
&lt;li&gt;connect to the server&lt;/li&gt;
&lt;li&gt;then begin TLS/SSL and HTTP communication&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So if DNS is unclear, TLS/SSL will always feel a little foggy too.&lt;/p&gt;

&lt;p&gt;Understanding DNS first makes the next networking topics much easier.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why developers should care about this
&lt;/h2&gt;

&lt;p&gt;It is easy to think:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Do I really need to know all this? I can just build apps.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can. For a while.&lt;/p&gt;

&lt;p&gt;But sooner or later, deeper understanding starts to matter.&lt;/p&gt;

&lt;p&gt;Maybe:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;your production request is slow&lt;/li&gt;
&lt;li&gt;your domain is not pointing to the right server&lt;/li&gt;
&lt;li&gt;your subdomain is broken&lt;/li&gt;
&lt;li&gt;your SSL setup is failing&lt;/li&gt;
&lt;li&gt;your infrastructure behaves differently across environments&lt;/li&gt;
&lt;li&gt;a tool's official docs feel harder than they should&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where fundamentals help.&lt;/p&gt;

&lt;p&gt;When you understand DNS, you stop treating networking like magic.&lt;/p&gt;

&lt;p&gt;You start seeing the path.&lt;/p&gt;

&lt;p&gt;And once you can see the path, debugging becomes easier.&lt;/p&gt;




&lt;h2&gt;
  
  
  A small story every developer can relate to
&lt;/h2&gt;

&lt;p&gt;Imagine this.&lt;/p&gt;

&lt;p&gt;You deploy your app.&lt;br&gt;
The code is fine.&lt;br&gt;
The server is running.&lt;br&gt;
But the site still does not open.&lt;/p&gt;

&lt;p&gt;At first, you think:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;is the backend broken?&lt;/li&gt;
&lt;li&gt;is the port wrong?&lt;/li&gt;
&lt;li&gt;is Nginx failing?&lt;/li&gt;
&lt;li&gt;is HTTPS misconfigured?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But the real problem turns out to be simple:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;the domain is not resolving correctly.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That one small DNS issue can make the whole app feel "down.”&lt;/p&gt;

&lt;p&gt;This is why solid developers do not only learn frameworks.&lt;/p&gt;

&lt;p&gt;They learn what happens around the request too.&lt;/p&gt;




&lt;h2&gt;
  
  
  The big lesson: do not skip the basics
&lt;/h2&gt;

&lt;p&gt;A lot of hard topics become easier when your basics are strong.&lt;/p&gt;

&lt;p&gt;Docker makes more sense.&lt;br&gt;
Kubernetes makes more sense.&lt;br&gt;
TLS/SSL makes more sense.&lt;br&gt;
Load balancers, CDNs, proxies, reverse proxies, and hosting all make more sense.&lt;/p&gt;

&lt;p&gt;Not because they are easy.&lt;/p&gt;

&lt;p&gt;But because you already understand the ground they stand on.&lt;/p&gt;

&lt;p&gt;Many developers struggle with official docs not because their English is bad, but because the underlying computer science concepts are still shaky.&lt;/p&gt;

&lt;p&gt;That is normal.&lt;/p&gt;

&lt;p&gt;And the fix is not shortcuts.&lt;/p&gt;

&lt;p&gt;The fix is going back, learning the core ideas properly, and revisiting them again and again until they feel natural.&lt;/p&gt;

&lt;p&gt;That is how real confidence is built.&lt;/p&gt;

</description>
      <category>dns</category>
      <category>networking</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Demystifying TCP: How the Internet Actually Sends Your Data (Without Losing It)</title>
      <dc:creator>Tahsin Abrar</dc:creator>
      <pubDate>Mon, 13 Apr 2026 07:58:22 +0000</pubDate>
      <link>https://forem.com/tahsin000/demystifying-tcp-how-the-internet-actually-sends-your-data-without-losing-it-53le</link>
      <guid>https://forem.com/tahsin000/demystifying-tcp-how-the-internet-actually-sends-your-data-without-losing-it-53le</guid>
      <description>&lt;p&gt;Let’s be honest for a second. When we write code to fetch data from a server, we usually don't think twice about how it gets there. We write a simple JavaScript &lt;code&gt;fetch()&lt;/code&gt; call, hit save, and boom our frontend talks to our backend.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://api.example.com/data&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello World&lt;/span&gt;&lt;span class="dl"&gt;"&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;To us, it feels like magic. We just say "send this," and it arrives. But the Application Layer (where our code lives) is blissfully unaware of the chaotic, noisy, and unpredictable journey that data takes across the internet.&lt;/p&gt;

&lt;p&gt;The real unsung hero making sure your "Hello World" doesn't turn into a corrupted mess of random bytes is the Transport Layer specifically, the TCP (Transmission Control Protocol).&lt;/p&gt;

&lt;p&gt;Today, we are going to look under the hood. No dry, boring textbook definitions. Just a practical, developer-friendly look at how TCP actually works, how it keeps our data safe, and why understanding it will make you a much better software engineer.&lt;/p&gt;




&lt;h3&gt;
  
  
  What is TCP, Really?
&lt;/h3&gt;

&lt;p&gt;Imagine you are mailing a 1,000-page manuscript to a publisher, but the post office only allows you to send one page per envelope.&lt;/p&gt;

&lt;p&gt;If you just dump 1,000 envelopes into the mailbox, what happens? Some might get lost. Some might arrive out of order. The publisher would be hopelessly confused.&lt;/p&gt;

&lt;p&gt;TCP is the ultimate postal manager. It chops your big data into smaller pieces called &lt;strong&gt;segments&lt;/strong&gt;, numbers them, sends them, and waits for a receipt. If a piece goes missing or gets corrupted, TCP demands that it be sent again.&lt;/p&gt;

&lt;p&gt;That’s why the "C" in TCP stands for &lt;strong&gt;Control&lt;/strong&gt;. It controls the transmission so you don't have to.&lt;/p&gt;

&lt;p&gt;To do this, TCP breaks communication down into three distinct phases:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7hgjwqpxfeigd7h87mlj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7hgjwqpxfeigd7h87mlj.png" alt=" " width="800" height="596"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;The Setup&lt;/strong&gt; (Three-way Handshake)&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;The Data Transfer&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;The Teardown&lt;/strong&gt; (Four-way Finishing)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s walk through them.&lt;/p&gt;




&lt;h3&gt;
  
  
  Phase 1: The Three-Way Handshake 🤝
&lt;/h3&gt;

&lt;p&gt;Before TCP sends a single byte of your actual data, it needs to make sure the server is awake, willing, and ready to talk. It does this using a process called the Three-Way Handshake.&lt;/p&gt;

&lt;p&gt;Imagine calling a friend on the phone:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;You:&lt;/strong&gt; "Hey, are you there? Can you hear me?" &lt;em&gt;(SYN)&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Friend:&lt;/strong&gt; "Yeah, I hear you! Can you hear me?" &lt;em&gt;(SYN-ACK)&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;You:&lt;/strong&gt; "Loud and clear. Let's talk." &lt;em&gt;(ACK)&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In TCP terms, it looks like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SYN (Synchronize):&lt;/strong&gt; The Client sends a packet with the SYN flag turned on. It says, "I want to connect, and I'm starting my sequence at number 1000."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SYN-ACK (Synchronize-Acknowledge):&lt;/strong&gt; The Server replies. "I got your request (ACK 1001), and I also want to connect. My sequence starts at 2000" (SYN).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ACK (Acknowledge):&lt;/strong&gt; The Client sends one final confirmation. "Got it. I'm ready for your data starting at 2001."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Boom. The connection is established. Now, they can safely send data.&lt;/p&gt;




&lt;h3&gt;
  
  
  What’s Inside a TCP Segment? (The Anatomy of a Header)
&lt;/h3&gt;

&lt;p&gt;When TCP chops up your data, it doesn't just send raw text. It wraps your data in a &lt;strong&gt;Header&lt;/strong&gt; a block of metadata that contains all the instructions for delivery.&lt;/p&gt;

&lt;p&gt;A TCP header is usually between 20 and 60 bytes. Let's break down the coolest parts of this header.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. The Ports (Source &amp;amp; Destination)
&lt;/h4&gt;

&lt;p&gt;You probably know that an HTTP server runs on port 80, HTTPS on 443, and your local React app maybe on 3000. But have you ever wondered what port the client (your browser) uses to make the request?&lt;/p&gt;

&lt;p&gt;The TCP header reserves 16 bits each for the Source Port and the Destination Port. 16 bits means $2^{16} - 1$, which gives us a maximum of 65,535 possible ports.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Well-known ports (0 - 1023):&lt;/strong&gt; Reserved for big stuff. (80 for HTTP, 443 for HTTPS, 22 for SSH).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Registered ports (1024 - 49151):&lt;/strong&gt; Used by specific apps (like MySQL on 3306).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ephemeral / Dynamic ports (49152 - 65535):&lt;/strong&gt; This is the secret sauce! &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When your browser makes a request to Facebook (port 443), your Operating System randomly grabs an unused Ephemeral port (let's say 50153) and assigns it to your browser. So the request goes from &lt;code&gt;Your_IP:50153&lt;/code&gt; to &lt;code&gt;Facebook_IP:443&lt;/code&gt;. When Facebook replies, it knows exactly to send the data back to port 50153, so it reaches your exact browser tab!&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Sequence &amp;amp; Acknowledgment Numbers
&lt;/h4&gt;

&lt;p&gt;These are the page numbers of our manuscript analogy.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sequence Number:&lt;/strong&gt; "This is byte number 1001 of my data."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ACK Number:&lt;/strong&gt; "I successfully received up to byte 1005. Please send byte 1006 next."&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  3. Window Size (Flow Control)
&lt;/h4&gt;

&lt;p&gt;Imagine trying to drink from a firehose. You'd drown. Servers can experience the same thing if a client sends data too fast.&lt;/p&gt;

&lt;p&gt;The Window Size is the server politely saying: "Listen, I can only handle 10,000 bytes at a time right now. Don't send me more than that until I acknowledge receipt, or I'll crash." This prevents overwhelming the receiver.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. The Checksum (Error Detection)
&lt;/h4&gt;

&lt;p&gt;As data travels across the ocean through fiber optic cables, routers, and Wi-Fi signals, electrical interference can flip a bit (turn a 0 into a 1). Your "I love you" might suddenly turn into "I hate you".&lt;/p&gt;

&lt;p&gt;To fix this, TCP uses a Checksum. Before sending, the sender takes all the data, adds it up in a specific binary way, flips the bits (One's Complement), and puts that value in the Checksum field.&lt;/p&gt;

&lt;p&gt;When the receiver gets it, they do the exact same math. If their result doesn't perfectly match, they know the data got corrupted in transit. They silently drop the corrupted segment, forcing the sender to re-transmit it.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Flags
&lt;/h4&gt;

&lt;p&gt;These are tiny 1-bit switches that tell the receiver what kind of segment this is. Is it a setup request (SYN)? Is it an acknowledgment (ACK)? Or is it time to close the connection (FIN)?&lt;/p&gt;




&lt;h3&gt;
  
  
  Phase 2: Sending the Data
&lt;/h3&gt;

&lt;p&gt;Once the handshake is done, the actual data transfer begins.&lt;/p&gt;

&lt;p&gt;Let's say we are sending the string "Hello World". Based on the Maximum Segment Size (MSS) agreed upon during the handshake, TCP might split this into multiple segments.&lt;/p&gt;

&lt;p&gt;The client sends "Hell", the server ACKs it. The client sends "o Wo", the server ACKs it.&lt;/p&gt;

&lt;p&gt;Because of the Window Size, the client doesn't actually have to wait for an ACK after every single segment. If the window is large enough, it can blast 10 segments at once, and the server can send a single ACK saying, "Yep, got all 10!"&lt;/p&gt;

&lt;p&gt;If an ACK never arrives, the sender's internal timer runs out, and it assumes the data was lost in the void. It then resends the data. That's the beauty of it it guarantees delivery.&lt;/p&gt;




&lt;h3&gt;
  
  
  Phase 3: The Four-Way Teardown 👋
&lt;/h3&gt;

&lt;p&gt;When the client is done sending data, it doesn't just hang up the phone. It's polite. It initiates a Four-Way Teardown.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Client:&lt;/strong&gt; Sends a FIN (Finish) flag. &lt;em&gt;"I'm done sending data."&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server:&lt;/strong&gt; Sends an ACK. &lt;em&gt;"Understood, you're done."&lt;/em&gt; (At this point, the server might still have a little bit of its own data left to send back to the client. The client will wait and listen).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server:&lt;/strong&gt; Sends its own FIN. &lt;em&gt;"Okay, I'm done sending data too."&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Client:&lt;/strong&gt; Sends a final ACK. &lt;em&gt;"Got it. Goodbye forever."&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The connection is closed, and the OS frees up the ephemeral port to be used by another application later.&lt;/p&gt;




&lt;h3&gt;
  
  
  Why Should You Care as a Developer?
&lt;/h3&gt;

&lt;p&gt;You might be thinking, "This is cool, but my framework handles this. Why do I need to know it?"&lt;/p&gt;

&lt;p&gt;Because things break.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When your API requests start timing out, understanding the Three-way Handshake helps you debug if a firewall is blocking your SYN packets.&lt;/li&gt;
&lt;li&gt;When you wonder why you can't run two node servers on port 3000, you now understand how Ports bind to processes.&lt;/li&gt;
&lt;li&gt;When you design high-traffic systems, understanding Window Size helps you realize why servers get overwhelmed and drop connections.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding TCP is like moving from driving an automatic car to a manual transmission. You don't have to think about the gears every day, but when you're stuck in the mud, knowing exactly how the engine connects to the wheels is what gets you out.&lt;/p&gt;

</description>
      <category>networking</category>
      <category>tcp</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Why We Talk OSI but Live in a TCP/IP World (A Developer’s Guide)</title>
      <dc:creator>Tahsin Abrar</dc:creator>
      <pubDate>Sun, 12 Apr 2026 10:55:37 +0000</pubDate>
      <link>https://forem.com/tahsin000/why-we-talk-osi-but-live-in-a-tcpip-world-a-developers-guide-140o</link>
      <guid>https://forem.com/tahsin000/why-we-talk-osi-but-live-in-a-tcpip-world-a-developers-guide-140o</guid>
      <description>&lt;p&gt;If you’ve ever sat in a tech meeting and nodded along while another engineer threw around terms like "Layer 7 load balancing" or "L4 routing," you aren't alone. &lt;/p&gt;

&lt;p&gt;We talk about networking a lot in software development, but there’s a funny quirk in our industry: the model we learn in textbooks isn't exactly the model that runs the internet. &lt;/p&gt;

&lt;p&gt;In our last deep dive, we talked about the OSI model a beautiful, theoretical 7-layer philosophy. But out in the wild? The entire world runs on the &lt;strong&gt;TCP/IP model&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Today, let's bridge the gap between theory and reality, figure out how data actually moves across the internet, and look at the only layers you actually need to care about as a software engineer.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Reality Check: 7 Layers vs. 5 Layers
&lt;/h3&gt;

&lt;p&gt;The OSI model breaks networking down into 7 distinct layers. But the TCP/IP model, which is what actually powers the internet today, condenses things down to just 5 layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Application Layer&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Transport Layer&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network Layer&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Data Link Layer&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physical Layer&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Wait, what happened to the &lt;strong&gt;Presentation&lt;/strong&gt; and &lt;strong&gt;Session&lt;/strong&gt; layers from the OSI model? &lt;/p&gt;

&lt;p&gt;In the real world, they didn't disappear; they just got absorbed. When you are building a modern web app say, a Nuxt.js frontend communicating with a Laravel backend your browser and framework handle everything at once. &lt;/p&gt;

&lt;p&gt;When you type "Hello" in a chat app, the Application Layer formats that text into JSON (what the Presentation layer used to do), compresses it, converts it to binary, and even checks if the other person is online with that little green dot (what the Session layer used to do). Because the Application Layer handles all of this heavy lifting, the TCP/IP model just groups them together.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Crucial Developer Rule:&lt;/strong&gt; Even though the TCP/IP model condensed the top layers, we still use OSI numbering in our everyday developer conversations! We still call the Application Layer &lt;strong&gt;L7&lt;/strong&gt;. We call the Transport layer &lt;strong&gt;L4&lt;/strong&gt;, Network is &lt;strong&gt;L3&lt;/strong&gt;, and Data Link is &lt;strong&gt;L2&lt;/strong&gt;. If you ever call the Application layer "L5," other engineers will look at you funny. Always stick to the L7 terminology!&lt;/p&gt;




&lt;h3&gt;
  
  
  Layer 4: The Transport Layer (TCP vs. UDP)
&lt;/h3&gt;

&lt;p&gt;Once your application has prepped the data, it hits the Transport Layer. This is where we decide &lt;em&gt;how&lt;/em&gt; the data is going to travel, and you have two main choices: &lt;strong&gt;TCP&lt;/strong&gt; or &lt;strong&gt;UDP&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  TCP (Transmission Control Protocol)
&lt;/h4&gt;

&lt;p&gt;Think of TCP as the highly reliable, slightly slower courier who requires a signature on delivery. It is 100% controlled. &lt;/p&gt;

&lt;p&gt;Imagine you are sending a text message that says "I LOVE YOU." If the data gets scrambled and arrives as "O I V E U Y," you're going to have a bad time. For text, JSON payloads, important API requests, or critical database transactions, we use TCP. It ensures every single piece of data arrives in the exact right order. When using TCP, your data is broken down into chunks called &lt;strong&gt;Segments&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  UDP (User Datagram Protocol)
&lt;/h4&gt;

&lt;p&gt;UDP is the fast, reckless delivery driver throwing newspapers onto your porch without stopping. It doesn't care if a few get lost in the bushes. &lt;/p&gt;

&lt;p&gt;We use UDP for things like live video streaming. If a stream contains 10 million frames and a couple of them drop out, your screen might glitch for a fraction of a second, but the video keeps playing. You wouldn't want the whole live stream to pause just to retrieve one missing frame. When using UDP, your data is broken down into chunks called &lt;strong&gt;Datagrams&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Moving Down the Stack: L3 to L1
&lt;/h3&gt;

&lt;p&gt;After the Transport Layer, the data keeps moving down the chain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Network Layer (L3):&lt;/strong&gt; This is where IP addresses come in. Your data (the Segment or Datagram) gets tagged with the Sender's IP and the Receiver's IP. Once those are attached, the whole package is now called a &lt;strong&gt;Packet&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Link Layer (L2):&lt;/strong&gt; Here, we attach MAC addresses to figure out the physical hardware hops the packet needs to take.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Physical Layer (L1):&lt;/strong&gt; Finally, everything is converted into 1s and 0s raw electrical signals or light pulses shooting through cables. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;A quick note for my fellow software engineers:&lt;/em&gt; You really only need to master L7, L4, L3, and L2. Unless you have a burning desire to become an electrical engineer, you can safely let the hardware folks worry about the Physical Layer!&lt;/p&gt;




&lt;h3&gt;
  
  
  A Quick Trip Back to 1969
&lt;/h3&gt;

&lt;p&gt;You might be wondering: if OSI is the standard, why is TCP/IP so different? &lt;/p&gt;

&lt;p&gt;It actually comes down to the Cold War. In 1969, the US Defense Department created an organization called ARPANET. They needed a decentralized network where data could survive even if computers or physical locations were destroyed in a war. Over the next decade, they actively developed the TCP/IP model. &lt;/p&gt;

&lt;p&gt;It was messy, organic, and random. In fact, TCP was being used to send data long before IP addresses were even a standard! The beautifully organized, perfectly logical OSI model didn't actually come along until 1984 to try and make sense of it all. We teach OSI first because it's fundamentally easier to understand, but TCP/IP is the battle-tested system that won the internet.&lt;/p&gt;

</description>
      <category>networking</category>
      <category>webdev</category>
      <category>computerscience</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Demystifying Linux: How GNU, Shells, and Terminals Actually Work Together</title>
      <dc:creator>Tahsin Abrar</dc:creator>
      <pubDate>Tue, 07 Apr 2026 10:09:39 +0000</pubDate>
      <link>https://forem.com/tahsin000/demystifying-linux-how-gnu-shells-and-terminals-actually-work-together-4975</link>
      <guid>https://forem.com/tahsin000/demystifying-linux-how-gnu-shells-and-terminals-actually-work-together-4975</guid>
      <description>&lt;p&gt;If you've been working with Linux for a while, you probably know that "Linux" technically just refers to the kernel. But a kernel alone is not enough to give you a working computer. To get a complete Operating System (what we call a Linux Distribution, like Ubuntu or Fedora), you need a lot of other moving parts.&lt;/p&gt;

&lt;p&gt;Today, we're going to peel back the layers of a Linux operating system. We'll look at where the tools we use every day actually come from, the difference between a terminal and a shell, and what happens behind the scenes when you type a simple command.&lt;/p&gt;

&lt;p&gt;Let's dive in!&lt;/p&gt;

&lt;h2&gt;
  
  
  The Origin Story: Enter Richard Stallman and GNU
&lt;/h2&gt;

&lt;p&gt;To understand how Linux works today, we have to travel back to 1983. Back then, an operating system called Unix was highly popular among universities and large companies. The problem? Unix was proprietary and expensive.&lt;/p&gt;

&lt;p&gt;A programmer named &lt;strong&gt;Richard Stallman&lt;/strong&gt; didn't like this. He believed software, especially operating systems, should be free and accessible to everyone. So, he started the &lt;strong&gt;Free Software Foundation (FSF)&lt;/strong&gt; and launched the &lt;strong&gt;GNU Project&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fun fact: GNU is a recursive acronym that stands for "GNU's Not Unix!"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Stallman's team began building free, open-source replacements for all the essential pieces of Unix. Their plan was to build everything needed for an OS, so that anyone students, devs, or companies could piece together a free operating system.&lt;/p&gt;

&lt;p&gt;If you use open-source tools today, you owe a huge "thank you" to Stallman and the FSF.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Essential GNU Toolkit
&lt;/h2&gt;

&lt;p&gt;So, what exactly did the GNU project build? They created a massive bundle of tools that bridge the gap between human developers and the kernel. Here are the heavy hitters:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. GCC (GNU Compiler Collection)
&lt;/h3&gt;

&lt;p&gt;If you've ever written a C program, you know you can't just run the raw text. You need to compile it into binary machine code that the computer understands. GCC is the legendary compiler that makes this happen. Without it, the open-source world as we know it wouldn't exist.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. glibc (GNU C Library)
&lt;/h3&gt;

&lt;p&gt;This one is fascinating. When you write a simple &lt;code&gt;printf("Hello World");&lt;/code&gt; in C, did you know that &lt;code&gt;printf&lt;/code&gt; isn't actually a native part of the C language?&lt;/p&gt;

&lt;p&gt;Native C handles things like &lt;code&gt;if/else' statements and&lt;/code&gt;for' loops. But interacting with hardware (like printing to a screen, allocating memory, or reading files) requires talking to the kernel. &lt;strong&gt;glibc&lt;/strong&gt; is the massive library that provides functions like &lt;code&gt;printf&lt;/code&gt;, &lt;code&gt;scanf&lt;/code&gt;, and &lt;code&gt;malloc&lt;/code&gt;. It acts as a translator, taking your code and making the complex "system calls" to the kernel on your behalf.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. GNU Coreutils
&lt;/h3&gt;

&lt;p&gt;This is the toolbox you use every single day. Have you ever typed &lt;code&gt;ls&lt;/code&gt;, &lt;code&gt;cd&lt;/code&gt;, &lt;code&gt;cat&lt;/code&gt;, &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;cp&lt;/code&gt;, or &lt;code&gt;rm&lt;/code&gt;?&lt;br&gt;
These aren't just random words; they are individual, standalone programs bundled together in what we call the &lt;strong&gt;GNU Core Utilities&lt;/strong&gt; (or Coreutils). They run in the "user space" and allow you to interact with your system.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Visual Layer: Desktop Environments (DE)
&lt;/h2&gt;

&lt;p&gt;Okay, so we have the kernel (the engine) and the GNU utilities (the steering wheel and pedals). But how do we actually see what we are doing?&lt;/p&gt;

&lt;p&gt;That's where &lt;strong&gt;Desktop Environments (DE)&lt;/strong&gt; come in. When you install an OS and see a taskbar, window frames, a file explorer, and icons, you are looking at the DE.&lt;/p&gt;

&lt;p&gt;Here are a few popular ones:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GNOME:&lt;/strong&gt; The default for Ubuntu, Fedora, and Debian. It's modern and beginner-friendly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;KDE Plasma:&lt;/strong&gt; Popular on Arch and openSUSE. It's incredibly customizable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Aqua:&lt;/strong&gt; The proprietary desktop environment used by Apple for macOS (which includes the Finder and the Dock).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Desktop Environment is also responsible for giving you a &lt;strong&gt;Terminal&lt;/strong&gt;. On Ubuntu (GNOME), it's called GNOME Terminal. On KDE, it's called Konsole. The terminal is just a graphical window an interface that lets you type things. But it doesn't process the commands itself. For that, it needs a Shell.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Brains of the Operation: The Shell
&lt;/h2&gt;

&lt;p&gt;If the Terminal is just a blank window, the &lt;strong&gt;Shell&lt;/strong&gt; is the smart program running inside it.&lt;/p&gt;

&lt;p&gt;The Shell takes the text you type, interprets it, figures out what program you want to run (like an &lt;code&gt;ls&lt;/code&gt; command from the Coreutils), and hands that request over to the kernel. When the kernel is done, the Shell takes the output and prints it on your Terminal screen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Quick History of Shells:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;sh (Bourne Shell):&lt;/strong&gt; Created by Stephen Bourne at Bell Labs in 1977. The OG.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ksh (KornShell):&lt;/strong&gt; Created by David Korn in 1983, adding more features.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;bash (Bourne Again Shell):&lt;/strong&gt; The GNU project's free answer to the original Bourne shell. It became the default for almost all Linux distributions for decades.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;zsh (Z Shell):&lt;/strong&gt; A modern, highly customizable shell. If you use a modern Mac, &lt;code&gt;zsh&lt;/code&gt; is now the default&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>cli</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Stop Calling Docker a Tool: The Real Story Behind 'docker run hello-world'</title>
      <dc:creator>Tahsin Abrar</dc:creator>
      <pubDate>Mon, 06 Apr 2026 10:57:28 +0000</pubDate>
      <link>https://forem.com/tahsin000/docker-is-more-than-a-tool-understanding-the-docker-ecosystem-2ani</link>
      <guid>https://forem.com/tahsin000/docker-is-more-than-a-tool-understanding-the-docker-ecosystem-2ani</guid>
      <description>&lt;p&gt;Let’s get one thing straight right out of the gate: &lt;strong&gt;Docker is not just a tool.&lt;/strong&gt; It’s not just a simple application, and it’s certainly not just a piece of standalone software. &lt;/p&gt;

&lt;p&gt;If someone tells you Docker is just a software tool, you can confidently tell them they’ve been misled. &lt;/p&gt;

&lt;p&gt;So, what is it? &lt;strong&gt;Docker is a platform. It is an ecosystem.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To truly master Docker, you have to stop looking at it as a black box that magically runs your code, and start looking at it as a living, breathing ecosystem. Today, we are going to dive deep into how this ecosystem actually works.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdm5elw8iopsn546ord13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdm5elw8iopsn546ord13.png" alt=" " width="800" height="610"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Ecosystem Analogy
&lt;/h2&gt;

&lt;p&gt;Think about a biological ecosystem a food chain. An earthworm is eaten by a duck, the duck is caught by a snake, the snake is hunted by a mongoose, and the mongoose is swooped up by an eagle. &lt;/p&gt;

&lt;p&gt;For the ecosystem to function, every single piece of that chain has to exist and interact. Docker works exactly the same way. It is a chain of distinct technologies working together to create what we call the "Docker Platform."&lt;/p&gt;

&lt;p&gt;Before we look at the chain in action, let’s meet the main characters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Docker Client (CLI):&lt;/strong&gt; The interface where you type your commands.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Engine (dockerd):&lt;/strong&gt; The background daemon (the brain) that listens for API requests and manages Docker objects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Desktop:&lt;/strong&gt; The unsung hero for Mac and Windows users. It quietly creates a Linux Virtual Machine in the background so the Docker Engine has a Linux kernel to work with.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Images:&lt;/strong&gt; Think of an image as a "screenshot" or a frozen snapshot of a container. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Hub:&lt;/strong&gt; The massive, cloud-based database where all these images (like Ubuntu, Redis, Postgres, or Node) live.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Compose:&lt;/strong&gt; (We’ll save this one for a future post, but just know it’s the orchestrator for multi-container setups!)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Deep Dive: What actually happens when you hit Enter?
&lt;/h2&gt;

&lt;p&gt;Most developers know how to type &lt;code&gt;docker run hello-world&lt;/code&gt;. But what happens in the milliseconds after you hit enter? Let’s connect the dots.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ftk2isam7evu66e0yxr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ftk2isam7evu66e0yxr.png" alt=" " width="800" height="591"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: The Request
&lt;/h3&gt;

&lt;p&gt;You type &lt;code&gt;docker run hello-world&lt;/code&gt; into your terminal. The &lt;strong&gt;Docker Client&lt;/strong&gt; catches this command and translates it into a REST API request. It sends this request to the &lt;strong&gt;Docker Engine&lt;/strong&gt; (specifically, the &lt;code&gt;dockerd&lt;/code&gt; daemon).&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Passing the Baton
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;dockerd&lt;/code&gt; is a busy manager. It receives your request and says, &lt;em&gt;"Hey, **containerd&lt;/em&gt;* (the high-level container runtime), handle this for me."*&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: The Cache Check
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;containerd&lt;/code&gt; acts like a smart librarian. First, it checks its local cache. It asks: &lt;em&gt;"Do we already have the &lt;code&gt;hello-world&lt;/code&gt; image downloaded on this computer?"&lt;/em&gt; If this is your first time running it, the answer is no. &lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: The Download (Pulling)
&lt;/h3&gt;

&lt;p&gt;Because the image isn't stored locally, &lt;code&gt;containerd&lt;/code&gt; reaches out to &lt;strong&gt;Docker Hub&lt;/strong&gt;. It requests the &lt;code&gt;hello-world&lt;/code&gt; image, pulls it down, and caches it locally so it won't have to download it again next time. &lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: The Build
&lt;/h3&gt;

&lt;p&gt;Now that it has the image, &lt;code&gt;containerd&lt;/code&gt; hands it over to &lt;strong&gt;runc&lt;/strong&gt; (the low-level runtime) and says, &lt;em&gt;"Execute this."&lt;/em&gt; ### Step 6: The Kernel Magic&lt;br&gt;
Here is where the real magic happens. &lt;code&gt;runc&lt;/code&gt; talks directly to the &lt;strong&gt;Linux Kernel&lt;/strong&gt; (which, if you are on Mac/Windows, is provided by Docker Desktop). &lt;/p&gt;

&lt;p&gt;It asks the kernel for two very specific things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Namespaces:&lt;/strong&gt; To create an isolated "alternate reality" for the container so it can't see what else is running on your machine.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Control Groups (cgroups):&lt;/strong&gt; To set strict limits on how much RAM, CPU, and Hard Drive space this specific container is allowed to use.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The kernel agrees, builds this isolated little world, and the container is born!&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 7: The Response
&lt;/h3&gt;

&lt;p&gt;A new process starts inside that container, executes the &lt;code&gt;hello-world&lt;/code&gt; script, and sends a success message all the way back up the chain from the daemon, to the CLI, and finally onto your screen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens if you run it a second time?&lt;/strong&gt;&lt;br&gt;
Try running &lt;code&gt;docker run hello-world&lt;/code&gt; again. Notice how much faster it is? It completely skips Docker Hub. &lt;code&gt;containerd&lt;/code&gt; finds the image in the local cache, hands it straight to &lt;code&gt;runc&lt;/code&gt;, and the container spins up instantly. &lt;/p&gt;

&lt;h2&gt;
  
  
  The "Just Make it Work" Trap
&lt;/h2&gt;

&lt;p&gt;You might be wondering: &lt;em&gt;Why do I need to know all of this?&lt;/em&gt; Here is a hard truth: there are software engineers out there with 5 to 10 years of experience who couldn't explain what you just read. They never dive deep. They treat Docker as a magical black box because their only goal is to "just make it work." &lt;/p&gt;

&lt;p&gt;It’s easy to be lazy. It's easy to just copy-paste terminal commands. But taking the easy route puts a hard ceiling on your career.&lt;/p&gt;

&lt;p&gt;Think of your brain like a massive library. If you just throw random facts into it without organizing them, you'll never be able to find the information when a server crashes at 2 AM. But if you take the time to &lt;strong&gt;connect the dots&lt;/strong&gt; if you organize your knowledge logically, understanding &lt;em&gt;how&lt;/em&gt; &lt;code&gt;dockerd&lt;/code&gt; talks to &lt;code&gt;containerd&lt;/code&gt; you create a mental index. &lt;/p&gt;

&lt;p&gt;When you learn this way, you never forget. &lt;/p&gt;

</description>
      <category>docker</category>
      <category>containers</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The 3-Second Trap: Why Your HTML to Laravel Blade Conversions Are Loading So Slowly</title>
      <dc:creator>Tahsin Abrar</dc:creator>
      <pubDate>Sat, 04 Apr 2026 07:48:18 +0000</pubDate>
      <link>https://forem.com/tahsin000/the-3-second-trap-why-your-html-to-laravel-blade-conversions-are-loading-so-slowly-56fm</link>
      <guid>https://forem.com/tahsin000/the-3-second-trap-why-your-html-to-laravel-blade-conversions-are-loading-so-slowly-56fm</guid>
      <description>&lt;p&gt;You’re working on a shiny new admin dashboard. You found a gorgeous, lightning-fast static HTML template online. You download it, open the &lt;code&gt;index.html&lt;/code&gt; file in your browser, and it loads instantly. Perfect. &lt;/p&gt;

&lt;p&gt;You copy that HTML into your Laravel project, paste it into a fresh Blade view, fire up your local server, and hit refresh. &lt;/p&gt;

&lt;p&gt;...One second. &lt;br&gt;
...Two seconds. &lt;br&gt;
...Three seconds. &lt;/p&gt;

&lt;p&gt;Suddenly, the layout snaps into place, and the icons finally pop onto the screen. &lt;/p&gt;

&lt;p&gt;What just happened? How did a blazing-fast HTML file turn into a sluggish mess the moment it touched Laravel? &lt;/p&gt;

&lt;p&gt;If you’ve ever spent hours debugging this frustrating delay, you are not alone. As a software architect who has spent years building and scaling Laravel applications, I've seen countless developers fall into this exact trap. Today, we’re going to look at why this "delay dilemma" happens and exactly how to fix it.&lt;/p&gt;


&lt;h2&gt;
  
  
  The Root Cause: The Asset Linking Trap
&lt;/h2&gt;

&lt;p&gt;When converting a static HTML template to a Laravel Blade file, the most common mistake is treating the Blade file exactly like a plain HTML file. &lt;/p&gt;

&lt;p&gt;Because Blade fully supports standard HTML syntax, it’s incredibly tempting to just drag and drop your CSS, JS, and image folders into your project and leave the &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tags exactly as they were. &lt;/p&gt;

&lt;p&gt;It usually looks something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"css/style.css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"vendors/fontawesome/all.min.css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"js/main.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In a standard HTML environment, the browser looks for those files relative to where the HTML file sits in the folder structure. But in Laravel, your application is routed through the &lt;code&gt;public&lt;/code&gt; directory, and your URLs are dynamic. &lt;/p&gt;

&lt;h3&gt;
  
  
  The Delay Dilemma Explained
&lt;/h3&gt;

&lt;p&gt;When you leave those relative links in your Blade file, the browser gets confused. It tries to load the CSS or the web fonts for your icons asynchronously. But because the file path doesn't align with Laravel's routing structure, the server can't easily find the assets.&lt;/p&gt;

&lt;p&gt;Behind the scenes, the browser is hanging. It is desperately searching for prerequisite files especially icon web fonts and core stylesheets. This creates a massive bottleneck. The browser essentially pauses the visual rendering for 2 to 3 seconds while it figures out what to do with the missing or misaligned assets. Finally, it gives up or falls back, and your page abruptly snaps into view. &lt;/p&gt;

&lt;p&gt;You might look at your code and think, &lt;em&gt;"My CSS is there, why is it slow?"&lt;/em&gt; The truth is, your CSS might be trying to load, but the broken asset links are holding the rest of the page hostage.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Fix: Do It the Laravel Way
&lt;/h2&gt;

&lt;p&gt;To solve this, we need to stop relying on generic HTML relative paths and start using Laravel's built-in helper functions. Specifically, the &lt;code&gt;asset()&lt;/code&gt; helper.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;asset()&lt;/code&gt; function generates a full, absolute URL for your application based on your current request scheme (HTTP or HTTPS). It tells the browser &lt;em&gt;exactly&lt;/em&gt; where to look inside the &lt;code&gt;public&lt;/code&gt; directory, completely eliminating the guesswork and the load delay.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Move your assets&lt;/strong&gt;&lt;br&gt;
First, ensure all your template's &lt;code&gt;css&lt;/code&gt;, &lt;code&gt;js&lt;/code&gt;, &lt;code&gt;images&lt;/code&gt;, and &lt;code&gt;fonts&lt;/code&gt; folders are placed directly inside your Laravel project's &lt;code&gt;public&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Wrap your links&lt;/strong&gt;&lt;br&gt;
Next, go through your Blade file and update every single static asset link using the &lt;code&gt;{{ asset() }}&lt;/code&gt; syntax.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"{{ asset('css/style.css') }}"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"{{ asset('vendors/fontawesome/all.min.css') }}"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Don't forget your scripts and images!&lt;/strong&gt;&lt;br&gt;
This rule applies to everything. If it's a static file, it needs the &lt;code&gt;asset()&lt;/code&gt; helper.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"{{ asset('js/main.js') }}"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"{{ asset('images/logo.png') }}"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Dashboard Logo"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  A Real-Life Game Changer
&lt;/h2&gt;

&lt;p&gt;I remember mentoring a junior developer a few years ago who was completely stuck on this. They were building a massive admin portal and had spent an entire afternoon profiling database queries, thinking their backend code was making the page slow. &lt;/p&gt;

&lt;p&gt;I took one look at their &lt;code&gt;app.blade.php&lt;/code&gt; layout file and saw dozens of hardcoded &lt;code&gt;&amp;lt;link href="assets/..."&amp;gt;&lt;/code&gt; tags. We spent five minutes wrapping them in the &lt;code&gt;asset()&lt;/code&gt; helper. When we hit refresh, that painful 3-second delay was completely gone. The icons loaded instantly, and the page felt native and snappy again. &lt;/p&gt;

&lt;p&gt;It was a total game-changer for them.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>performance</category>
    </item>
    <item>
      <title>Fixing Git 'Repository Not Found' &amp; Multiple SSH Key Issues</title>
      <dc:creator>Tahsin Abrar</dc:creator>
      <pubDate>Sun, 22 Mar 2026 16:16:50 +0000</pubDate>
      <link>https://forem.com/tahsin000/fixing-git-repository-not-found-multiple-ssh-key-issues-14de</link>
      <guid>https://forem.com/tahsin000/fixing-git-repository-not-found-multiple-ssh-key-issues-14de</guid>
      <description>&lt;p&gt;If you’ve ever worked with multiple GitHub accounts and suddenly hit errors like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Repository not found&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Can’t clone or push to a private repo&lt;/li&gt;
&lt;li&gt;Git showing a weird name like &lt;strong&gt;"Pagol98"&lt;/strong&gt; in commits&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;…you’re not alone. This is one of those problems that looks confusing at first, but once you understand it, it becomes super easy to fix.&lt;/p&gt;

&lt;p&gt;In this post, I’ll walk you through the &lt;strong&gt;exact issues&lt;/strong&gt;, &lt;strong&gt;why they happen&lt;/strong&gt;, and a &lt;strong&gt;clean, real-world solution&lt;/strong&gt; you can reuse in any project.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Real Problem (What’s Going Wrong?)
&lt;/h2&gt;

&lt;p&gt;Let’s break it down into &lt;strong&gt;3 common issues&lt;/strong&gt; that often get mixed together:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Repository Not Found
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/username/tailadmin-blade-dashboard.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;remote: Repository not found.
fatal: repository not found
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 This usually means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The repo name is wrong (typo)&lt;/li&gt;
&lt;li&gt;The repo is private and you don’t have access&lt;/li&gt;
&lt;li&gt;You’re using the wrong account&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2. Multiple SSH Keys Confusion
&lt;/h3&gt;

&lt;p&gt;You created:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;id_ed25519&lt;/code&gt; (personal)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;id_work&lt;/code&gt; (work)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 But Git doesn’t know &lt;strong&gt;which key to use for which repo&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So sometimes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One repo works ✅&lt;/li&gt;
&lt;li&gt;Another repo fails ❌&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  3. 😅 Random Commit Name (like “Pagol98”)
&lt;/h3&gt;

&lt;p&gt;Git uses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;user.name&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;user.email&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If not set correctly → it uses old/default values.&lt;/p&gt;




&lt;h2&gt;
  
  
  Real-Life Scenario (Why This Happens)
&lt;/h2&gt;

&lt;p&gt;Let’s say:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You have &lt;strong&gt;2 GitHub accounts&lt;/strong&gt; → Personal + Work&lt;/li&gt;
&lt;li&gt;Both have &lt;strong&gt;different SSH keys&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;You clone using HTTPS or default SSH&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Git gets confused:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Which identity should I use?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And that’s where things break.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step-by-Step Fix (Clean &amp;amp; Professional Setup)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Create SSH Config File
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\Asus\.ssh\config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If not exists → create it.&lt;/p&gt;

&lt;p&gt;Now add this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Personal GitHub&lt;/span&gt;
Host github-personal
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_ed25519

&lt;span class="c"&gt;# Work GitHub&lt;/span&gt;
Host github-work
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_work
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 This is the &lt;strong&gt;magic step&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 2: Use SSH Instead of HTTPS
&lt;/h3&gt;

&lt;p&gt;❌ Don’t use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;https://github.com/username/repo.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Use SSH:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git@github.com:username/repo.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now modify it using your config:&lt;/p&gt;

&lt;h4&gt;
  
  
  👉 Personal repo:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone git@github-personal:username/repo.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  👉 Work repo:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone git@github-work:username/repo.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 3: Test SSH Connection
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-T&lt;/span&gt; git@github-personal
ssh &lt;span class="nt"&gt;-T&lt;/span&gt; git@github-work
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Expected:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hi username! You've successfully authenticated
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 4: Fix Git Commit Name
&lt;/h3&gt;

&lt;p&gt;Check current config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.name
git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.email
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set correct values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.name &lt;span class="s2"&gt;"Your Name"&lt;/span&gt;
git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.email &lt;span class="s2"&gt;"your-email@gmail.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Per-Repository Config (Best Practice)
&lt;/h3&gt;

&lt;p&gt;If you use multiple accounts, don’t rely only on global config.&lt;/p&gt;

&lt;p&gt;Inside a specific repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config user.name &lt;span class="s2"&gt;"Work Name"&lt;/span&gt;
git config user.email &lt;span class="s2"&gt;"work-email@gmail.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 This avoids mixing identities.&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 5: Verify Remote URL
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git remote &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure it shows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git@github-work:username/repo.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git@github-personal:username/repo.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;This is one of those issues every developer faces at some point—especially when juggling &lt;strong&gt;personal and work GitHub accounts&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The key takeaway is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Git doesn’t “understand accounts” — it only understands configuration.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Once you properly configure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SSH keys&lt;/li&gt;
&lt;li&gt;SSH config&lt;/li&gt;
&lt;li&gt;Git user info&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Everything becomes predictable and smooth.&lt;/p&gt;

</description>
      <category>github</category>
      <category>gittips</category>
      <category>developerlife</category>
      <category>versioncontrol</category>
    </item>
    <item>
      <title>How to Set Up Passwordless SSH Login with PuTTY.</title>
      <dc:creator>Tahsin Abrar</dc:creator>
      <pubDate>Sun, 22 Mar 2026 01:48:29 +0000</pubDate>
      <link>https://forem.com/tahsin000/how-to-set-up-passwordless-ssh-login-with-putty-16oj</link>
      <guid>https://forem.com/tahsin000/how-to-set-up-passwordless-ssh-login-with-putty-16oj</guid>
      <description>&lt;p&gt;If you’ve ever logged into your VPS again and again using a password, you already know how repetitive and risky it can be.&lt;/p&gt;

&lt;p&gt;There’s a better way.&lt;/p&gt;

&lt;p&gt;In professional server environments, developers almost always use &lt;strong&gt;SSH key-based authentication&lt;/strong&gt; instead of passwords. It’s faster, more secure, and honestly… once you set it up, you won’t want to go back.&lt;/p&gt;

&lt;p&gt;In this guide, I’ll walk you through how to set up &lt;strong&gt;passwordless SSH login using PuTTY&lt;/strong&gt; in a simple, practical way.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is Passwordless SSH Login?
&lt;/h2&gt;

&lt;p&gt;In simple terms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instead of typing a password every time&lt;/li&gt;
&lt;li&gt;You use a &lt;strong&gt;private key file&lt;/strong&gt; stored on your computer&lt;/li&gt;
&lt;li&gt;The server verifies it using a &lt;strong&gt;public key&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of it like this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Your server has a lock (public key), and your computer has the only matching key (private key)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;No password needed. Just instant access.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Generate SSH Key Pair Using PuTTYgen
&lt;/h2&gt;

&lt;p&gt;First, we need to create two keys:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Private Key (.ppk)&lt;/strong&gt; → stays on your PC&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Public Key&lt;/strong&gt; → goes to your server&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Steps:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open &lt;strong&gt;PuTTYgen&lt;/strong&gt; (comes with PuTTY)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Under &lt;strong&gt;Parameters&lt;/strong&gt;, select:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Ed25519&lt;/code&gt; (modern, faster, more secure than RSA)&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click &lt;strong&gt;Generate&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Move your mouse randomly (this generates randomness)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once done:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Click &lt;strong&gt;Save private key&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Save it somewhere &lt;strong&gt;safe&lt;/strong&gt; (very important ⚠️)&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Copy the public key from:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Public key for pasting into OpenSSH authorized_keys file
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 2: Add Public Key to Your VPS
&lt;/h2&gt;

&lt;p&gt;Now we tell the server: “This key is allowed to access you.”&lt;/p&gt;

&lt;h3&gt;
  
  
  Login to your VPS (last time using password)
&lt;/h3&gt;

&lt;p&gt;Then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; ~/.ssh
&lt;span class="nb"&gt;chmod &lt;/span&gt;700 ~/.ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Open authorized_keys file:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nano ~/.ssh/authorized_keys
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Paste your public key
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Right-click in PuTTY → it will paste automatically&lt;/li&gt;
&lt;li&gt;Then save:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ctrl + O → Enter → Ctrl + X
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Secure the file:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;600 ~/.ssh/authorized_keys
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 3: Configure PuTTY for One-Click Login
&lt;/h2&gt;

&lt;p&gt;Now comes the fun part no more typing anything 😄&lt;/p&gt;

&lt;h3&gt;
  
  
  Steps:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open &lt;strong&gt;PuTTY&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go to:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Connection → Data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Set:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Auto-login username: your_username (e.g., root / ubuntu)
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Go to:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Connection → SSH → Auth → Credentials
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Select your &lt;code&gt;.ppk&lt;/code&gt; file&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Go back to:
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Enter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Host Name (IP)&lt;/li&gt;
&lt;li&gt;Saved Session name (e.g., &lt;code&gt;My Production VPS&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Click &lt;strong&gt;Save&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Result: One Click Login
&lt;/h2&gt;

&lt;p&gt;From now on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open PuTTY&lt;/li&gt;
&lt;li&gt;Double-click your saved session&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You’re instantly logged in. No password. No hassle.&lt;/p&gt;




&lt;h2&gt;
  
  
  Real-Life Scenario
&lt;/h2&gt;

&lt;p&gt;Let’s say you’re deploying a Laravel project from GitHub to your VPS.&lt;/p&gt;

&lt;p&gt;Before:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Login with password every time&lt;/li&gt;
&lt;li&gt;Risk of brute-force attacks&lt;/li&gt;
&lt;li&gt;Slower CI/CD setup&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instant login using SSH key&lt;/li&gt;
&lt;li&gt;Easy automation (GitHub Actions, scripts)&lt;/li&gt;
&lt;li&gt;Much more secure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is exactly how most production servers are managed in real-world teams.&lt;/p&gt;




&lt;p&gt;Setting up SSH key-based login might feel a bit technical at first but it’s one of those upgrades that pays off immediately.&lt;/p&gt;

&lt;p&gt;You get:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Better security&lt;/li&gt;
&lt;li&gt;Faster access&lt;/li&gt;
&lt;li&gt;Easier automation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And honestly… once you start using it, typing passwords will feel outdated.&lt;/p&gt;

</description>
      <category>ssh</category>
      <category>devops</category>
      <category>security</category>
      <category>linux</category>
    </item>
    <item>
      <title>Why Port 8000 Suddenly Stopped Working on My Local Machine (and How I Fixed It)</title>
      <dc:creator>Tahsin Abrar</dc:creator>
      <pubDate>Sat, 10 Jan 2026 09:23:29 +0000</pubDate>
      <link>https://forem.com/tahsin000/why-port-8000-suddenly-stopped-working-on-my-local-machine-and-how-i-fixed-it-4a12</link>
      <guid>https://forem.com/tahsin000/why-port-8000-suddenly-stopped-working-on-my-local-machine-and-how-i-fixed-it-4a12</guid>
      <description>&lt;p&gt;A few days ago, I faced one of those &lt;strong&gt;annoying local development issues&lt;/strong&gt; that waste hours and make you question your sanity.&lt;/p&gt;

&lt;p&gt;I started my local server like I always do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;http://127.0.0.1:8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And suddenly… &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Failed to listen on 127.0.0.1:8000&lt;br&gt;
An attempt was made to access a socket in a way forbidden by its access permissions&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I tried ports &lt;strong&gt;8001, 8002, 8003… all the way to 8010&lt;/strong&gt;.&lt;br&gt;
Same error. Every. Single. Time.&lt;/p&gt;

&lt;p&gt;If this sounds familiar, this post is for you.&lt;/p&gt;


&lt;h2&gt;
  
  
  The Confusing Part
&lt;/h2&gt;

&lt;p&gt;The first thing any developer does is check if the port is already in use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;netstat &lt;span class="nt"&gt;-ano&lt;/span&gt; | findstr :8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 &lt;strong&gt;Nothing. Empty.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So the port is free… right?&lt;/p&gt;

&lt;p&gt;Wrong.&lt;/p&gt;

&lt;p&gt;This is where Windows tricks you.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Real Problem (The Part No One Tells You)
&lt;/h2&gt;

&lt;p&gt;On &lt;strong&gt;Windows&lt;/strong&gt;, some ports are &lt;strong&gt;reserved by the OS itself&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This usually happens because of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hyper-V&lt;/li&gt;
&lt;li&gt;WSL2&lt;/li&gt;
&lt;li&gt;Docker Desktop&lt;/li&gt;
&lt;li&gt;Windows NAT (WinNAT)&lt;/li&gt;
&lt;li&gt;VPN software&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even if &lt;strong&gt;no app is using the port&lt;/strong&gt;, Windows blocks it internally.&lt;/p&gt;

&lt;p&gt;That’s why:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;netstat&lt;/code&gt; shows nothing&lt;/li&gt;
&lt;li&gt;Your app still fails to start&lt;/li&gt;
&lt;li&gt;You lose time debugging the wrong thing&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How I Found the Truth
&lt;/h2&gt;

&lt;p&gt;Run this command &lt;strong&gt;as Administrator&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;&lt;span class="nb"&gt;netsh&lt;/span&gt; &lt;span class="kd"&gt;int&lt;/span&gt; &lt;span class="kd"&gt;ipv4&lt;/span&gt; &lt;span class="kd"&gt;show&lt;/span&gt; &lt;span class="kd"&gt;excludedportrange&lt;/span&gt; &lt;span class="kd"&gt;protocol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kd"&gt;tcp&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On my machine, I saw this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Start Port    End Port
7943          8042
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Boom.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Port &lt;strong&gt;8000 is inside that range&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows owns the port&lt;/li&gt;
&lt;li&gt;Your app is not allowed to bind to it&lt;/li&gt;
&lt;li&gt;No process will show up in &lt;code&gt;netstat&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why This Error Is So Frustrating
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The error message is unclear&lt;/li&gt;
&lt;li&gt;Nothing shows in port checks&lt;/li&gt;
&lt;li&gt;Reinstalling frameworks won’t help&lt;/li&gt;
&lt;li&gt;Killing processes won’t help&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I wasted time restarting apps when the problem was &lt;strong&gt;the OS itself&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Fixes (Pick What Fits You)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Option 1: Use a Different Port (Fastest &amp;amp; Safest)
&lt;/h3&gt;

&lt;p&gt;If you just want to move on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;8080
3000
5000
9000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example (Django):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python manage.py runserver 127.0.0.1:8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works &lt;strong&gt;without admin access&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Option 2: Disable Hyper-V (Best for Dev Machines)
&lt;/h3&gt;

&lt;p&gt;If you don’t need Hyper-V:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;&lt;span class="nb"&gt;dism.exe&lt;/span&gt; &lt;span class="na"&gt;/Online /Disable-Feature&lt;/span&gt;&lt;span class="nl"&gt;:Microsoft&lt;/span&gt;&lt;span class="na"&gt;-Hyper-V
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restart your PC&lt;/p&gt;

&lt;p&gt;This permanently frees ports like 8000.&lt;/p&gt;




&lt;h3&gt;
  
  
  Option 3: Shutdown WSL (Temporary)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;&lt;span class="kd"&gt;wsl&lt;/span&gt; &lt;span class="na"&gt;--shutdown
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Good if you only need a quick fix.&lt;/p&gt;




&lt;h3&gt;
  
  
  Option 4: Restart WinNAT
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;&lt;span class="nb"&gt;net&lt;/span&gt; &lt;span class="kd"&gt;stop&lt;/span&gt; &lt;span class="kd"&gt;winnat&lt;/span&gt;
&lt;span class="nb"&gt;net&lt;/span&gt; &lt;span class="nb"&gt;start&lt;/span&gt; &lt;span class="kd"&gt;winnat&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;⚠️ Requires Administrator access&lt;br&gt;
⚠️ May be temporary&lt;/p&gt;




&lt;h2&gt;
  
  
  What NOT to Do
&lt;/h2&gt;

&lt;p&gt;❌ Don’t reinstall Python / Node / Django&lt;br&gt;
❌ Don’t keep killing random processes&lt;br&gt;
❌ Don’t fight the firewall first&lt;br&gt;
❌ Don’t assume &lt;code&gt;netstat&lt;/code&gt; tells the full story&lt;/p&gt;

&lt;p&gt;This is &lt;strong&gt;not your app’s fault&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;If this post saved you time, feel free to share it with another developer who’s stuck staring at port 8000 right now 😄&lt;br&gt;
Happy coding! 🚀&lt;/p&gt;

</description>
      <category>backend</category>
      <category>networking</category>
      <category>debugging</category>
      <category>windows</category>
    </item>
  </channel>
</rss>
