Release my port! How to Free Up a Used Port in Linux

Search for a command to run...

No comments yet. Be the first to comment.
Remember my post about switching to VSCode? Well, plot twist: the very next day after publishing it, I switched to WebStorm. And guess what? I've been on JetBrains IDEs ever since. I know, I know. Another "why I switched editors" post. But hear me ou...

I had been doing some basic interpreter work in Go and wanted to redo it in another language to solidify my understanding. Naturally, I chose Odin, it’s another great language, with a Go-like, easy-to-approach syntax and no unnecessary complexity. I ...

Why Emacs Keybindings? I've always preferred Emacs-style editing, especially the way it handles cursor movement and text manipulation. Even though I have switched to using VSCode for most of my development work, I often found myself missing the intui...

In my previous post about building C/C++ projects with CMake, I shared a simple CMakeLists.txt setup for compiling a basic project. Today, I’ll dive into a specific need that many developers encounter: linking libraries directly from project folders ...

Some time ago, I wrote a post about using Vim to look cool and why that’s not a good idea. Now, funny enough, here I am—having switched to VSCode after years of hopping between Vim and Emacs. This isn’t one of those "Vim sucks, I'm going back to VSCo...

You're in the middle of some exciting web development, everything's going smoothly, and then—bam! You hit an error message that throws a wrench in your plans:
Error: listen EADDRINUSE: address already in use 0.0.0.0:3022
Okay, so the port you need is already in use. Now what? You decide to ask some AI chatbot for help, hoping it can quickly point you in the right direction.
You type in something like:
"Hey robot, how do I find out which process is using a specific port in Linux? I'm getting this EADDRINUSE error for port 3022."
And sure enough, the bot does its thing and gives you a simple, clear solution:
Open up your terminal and run:
$ sudo lsof -i :3022
This command lists all the processes using port 3022, along with their Process IDs (PIDs). Now you've got the culprit!
Once you have the PID, freeing up the port is as easy as:
$ sudo kill -9 <PID>
Just replace <PID> with the actual number from the previous command. If you're not sure about killing a process, you can always try restarting your system or changing the port number your application is trying to use.
With this quick fix, you're back in action and ready to continue your work. Sometimes, a little nudge in the right direction is all you need to solve these annoying little problems.
Closing Thoughts
Running into port conflicts can be a bit frustrating, especially when you’re in the flow of coding. But with a couple of terminal commands, you can easily resolve the issue and get back to what really matters—building and creating. So next time you hit this snag, remember this quick trick!