<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: OneLineDev</title>
    <description>The latest articles on DEV Community by OneLineDev (@onelinedev).</description>
    <link>https://dev.to/onelinedev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4161905%2Fbf82cefd-60c1-4829-a3c0-48f52675c3e8.png</url>
      <title>DEV Community: OneLineDev</title>
      <link>https://dev.to/onelinedev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/onelinedev"/>
    <language>en</language>
    <item>
      <title>Fix: 'Address Already in Use' (Kill Stuck Process on Any Port)</title>
      <dc:creator>OneLineDev</dc:creator>
      <pubDate>Sun, 04 Oct 2026 16:04:53 +0000</pubDate>
      <link>https://dev.to/onelinedev/fix-address-already-in-use-kill-stuck-process-on-any-port-7ok</link>
      <guid>https://dev.to/onelinedev/fix-address-already-in-use-kill-stuck-process-on-any-port-7ok</guid>
      <description>&lt;h2&gt;
  
  
  The Error
&lt;/h2&gt;

&lt;p&gt;You start your local server (Node, Python, Go, Docker) and get stopped in your tracks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: listen EADDRINUSE: address already in use :::3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(or &lt;code&gt;bind: address already in use :8080&lt;/code&gt;)&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why It Happens
&lt;/h3&gt;

&lt;p&gt;An orphaned background process or crashed terminal session didn't release the TCP socket. Your operating system prevents two applications from listening on the exact same port simultaneously.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ Linux &amp;amp; macOS: Instant One-Liner Fix
&lt;/h2&gt;

&lt;p&gt;Replace &lt;code&gt;3000&lt;/code&gt; with your blocked port number:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx kill-port 3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Native Terminal Alternatives (No Node required):
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Option A (Using &lt;code&gt;fuser&lt;/code&gt;):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fuser &lt;span class="nt"&gt;-k&lt;/span&gt; 3000/tcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Option B (Using &lt;code&gt;lsof&lt;/code&gt; + &lt;code&gt;kill&lt;/code&gt;):&lt;/strong&gt;&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;kill&lt;/span&gt; &lt;span class="nt"&gt;-9&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;lsof &lt;span class="nt"&gt;-t&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt;:3000&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  ⚡ Windows: Instant Fix
&lt;/h2&gt;

&lt;h3&gt;
  
  
  In PowerShell (One-Liner):
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;Stop-Process&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-Id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Get-NetTCPConnection&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-LocalPort&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;OwningProcess&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-Force&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  In CMD (Command Prompt):
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Find the Process ID (PID):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   netstat -ano | findstr :3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Kill the process using the PID from the rightmost column:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   taskkill /PID &amp;lt;PID&amp;gt; /F
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Quick Tip
&lt;/h2&gt;

&lt;p&gt;If you frequently run into this issue during development, install &lt;code&gt;kill-port&lt;/code&gt; globally so you can blast any port from any terminal in 1 second:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; kill-port
kill-port 3000 8080 5000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>linux</category>
      <category>webdev</category>
      <category>devops</category>
      <category>programming</category>
    </item>
    <item>
      <title>Fix: 'fatal: refusing to merge unrelated histories' in Git</title>
      <dc:creator>OneLineDev</dc:creator>
      <pubDate>Sun, 04 Oct 2026 15:58:53 +0000</pubDate>
      <link>https://dev.to/onelinedev/fix-fatal-refusing-to-merge-unrelated-histories-in-git-42bh</link>
      <guid>https://dev.to/onelinedev/fix-fatal-refusing-to-merge-unrelated-histories-in-git-42bh</guid>
      <description>&lt;h2&gt;
  
  
  The Error
&lt;/h2&gt;

&lt;p&gt;You run &lt;code&gt;git pull&lt;/code&gt; or &lt;code&gt;git merge&lt;/code&gt; and see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fatal: refusing to merge unrelated histories
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why It Happens
&lt;/h3&gt;

&lt;p&gt;Git refuses to merge branches that do not share a common ancestor commit. This typically happens when you created a local repo with &lt;code&gt;git init&lt;/code&gt;, created a remote repository on GitHub with a default &lt;code&gt;README.md&lt;/code&gt; or &lt;code&gt;.gitignore&lt;/code&gt;, and then tried to connect them.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Quick Fix (One-Liner)
&lt;/h2&gt;

&lt;p&gt;Force Git to merge the two independent project histories:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git pull origin main &lt;span class="nt"&gt;--allow-unrelated-histories&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(Note: Replace &lt;code&gt;main&lt;/code&gt; with &lt;code&gt;master&lt;/code&gt; if your default branch is named &lt;code&gt;master&lt;/code&gt;)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you are merging directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git merge origin/main &lt;span class="nt"&gt;--allow-unrelated-histories&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Resolving the Merge &amp;amp; Pushing
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;If an editor opens for a commit message&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Vim&lt;/strong&gt;: Type &lt;code&gt;:wq&lt;/code&gt; and hit &lt;code&gt;Enter&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nano&lt;/strong&gt;: Press &lt;code&gt;Ctrl + O&lt;/code&gt;, &lt;code&gt;Enter&lt;/code&gt;, then &lt;code&gt;Ctrl + X&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;If merge conflicts occur&lt;/strong&gt;:&lt;br&gt;
Open the conflicting files (e.g., &lt;code&gt;README.md&lt;/code&gt;), choose which lines to keep, save, and run:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git add &lt;span class="nb"&gt;.&lt;/span&gt;
   git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"chore: merge unrelated histories"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Push to Remote&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git push &lt;span class="nt"&gt;-u&lt;/span&gt; origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Alternative: Overwrite Local with Remote
&lt;/h2&gt;

&lt;p&gt;If your local commits don't matter and you just want the remote repository's exact state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git fetch origin
git reset &lt;span class="nt"&gt;--hard&lt;/span&gt; origin/main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Warning&lt;/strong&gt;: &lt;code&gt;reset --hard&lt;/code&gt; permanently discards uncommitted local changes.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>devops</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
