惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
J
Java Code Geeks
Vercel News
Vercel News
A
About on SuperTechFans
G
Google Developers Blog
C
Check Point Blog
腾讯CDC
N
Netflix TechBlog - Medium
博客园 - 司徒正美
S
SegmentFault 最新的问题
D
DataBreaches.Net
博客园_首页
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
量子位
雷峰网
雷峰网
IT之家
IT之家
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
博客园 - 三生石上(FineUI控件)
H
Help Net Security
宝玉的分享
宝玉的分享
博客园 - 叶小钗

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How to Find and Stop the Process Using a Port on Linux
tkpdx01 · 2026-06-14 · via DEV Community

tkpdx01

When you start a service and it fails with address already in use, something else is already holding the port. On a Linux server you can identify that process and stop it in three short steps. This guide uses ss and kill on Ubuntu 22.04, but the approach works on any modern distribution.

Step 1 - Find What Is Listening on the Port

Use ss, the modern replacement for netstat, to list the process bound to a port — here, port 8080:

sudo ss -ltnp 'sport = :8080'

The flags read as -l listening sockets, -t TCP, -n numeric ports (don't resolve names), and -p show the owning process. The output ends with a users:(...) field naming the program and its process ID (PID):

State   Recv-Q  Send-Q  Local Address:Port  Peer Address:Port  Process
LISTEN  0       511     0.0.0.0:8080        0.0.0.0:*          users:(("nginx",pid=1432,fd=6))

Here the PID is 1432. The sudo matters: without it, ss hides process details for sockets you don't own.

Step 2 - Confirm the Process Before You Touch It

Never kill a PID you haven't looked at. Check what it actually is:

ps -p 1432 -o pid,user,cmd

This prints the full command line and owning user, so you can be sure you're stopping the right thing and not a system service you depend on:

  PID USER     CMD
 1432 www-data /usr/sbin/nginx -g daemon on; master_process on;

Step 3 - Stop It Gracefully, Then Forcefully

Ask the process to shut down cleanly first with a TERM signal (the default), which lets it close connections and flush state:

sudo kill 1432

Wait a second or two, then re-run the Step 1 command. If the port is free, you're done. If the process ignored TERM and is still listening, escalate to KILL, which the process cannot trap or ignore:

sudo kill -9 1432

Reserve kill -9 for stuck processes only — it gives the program no chance to clean up, which can leave temporary files or stale sockets behind.

Conclusion

You located the process bound to a port with ss -ltnp, verified it with ps, and stopped it with an escalating kill. Saving sudo ss -ltnp 'sport = :PORT' as a shell alias makes the next "address already in use" error a ten-second fix.