Skip to content

ovack/PortList

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PortList

A minimal, native macOS utility that lists the listening ports currently occupied by non-system processes and lets you release any of them with a single click or a double-click.

PortList screenshot


Features

  • 🔍 Automatic scan — on launch, the app automatically lists the TCP listening ports on your machine.
  • 🧹 Smart filtering — a sidebar groups ports so you can view All Ports, Non-system, System, or filter by protocol (TCP / UDP). Each group shows a live count.
  • 🃏 Clickable stat cards — the tiles at the top (Listening Ports / Non-system / System) are clickable and act as filters, keeping the view in sync with the sidebar.
  • 🚫 One-click (or double-click) release — click the Release button on any row, or double-click anywhere on the row, to free that port. A confirmation dialog appears before anything is killed.
  • 🔎 Live search — filter instantly by port number, process name, or executable path.
  • 📂 Detailed process info — every row shows the port, protocol, address, process name, PID, and the launch path of the program holding the port (e.g. /usr/local/bin/node).
  • 🔄 Rescan with feedback — the refresh button re-scans the system and shows a toast (Rescanned — N ports in total) when done. A ? tip button next to it explains the double-click shortcut.
  • 🪟 Native macOS design — built with SwiftUI + AppKit and the modern Liquid Glass look, fully dark-mode aware, no third-party dependencies.
  • 🌐 Localized — the interface is available in Simplified Chinese and English, and follows your system language automatically.

How "non-system ports" are defined

The app reads listening ports via lsof -iTCP -sTCP:LISTEN and uses ps to resolve each process's full executable path and owning user. A process is classified as system when:

  • its executable lives under /System/, /usr/libexec/, /Library/Apple/, /usr/sbin/, or /sbin/;
  • its name is a known system daemon (e.g. launchd, mDNSResponder, WindowServer);
  • it runs as root from an Apple system directory.

By default lsof only returns ports for the current user's own processes, which naturally matches the "non-system ports" intent. Use the sidebar to reveal system ports when needed (terminating root processes requires permission).

How "release" works

After you confirm, ProcessKiller does the following:

  1. Sends SIGTERM (kill -TERM <pid>) for a graceful shutdown, waiting up to ~1.5s.
  2. If the process is still alive, sends SIGKILL (kill -KILL <pid>) to force-kill it.
  3. Re-scans to refresh the list.

Permissions: the app runs as the current user and can only terminate processes it owns. To release a port held by a root system process, launch the app with sudo (not recommended unless you know exactly what you are doing).

Localization

The UI ships in Simplified Chinese and English and follows the system language by default (change it in System Settings → Language & Region). All translations live in PortList/Localizable.xcstrings; to add another language, add a localization for that catalog in Xcode — no code changes required.


PortList(中文)

一个简洁的原生 macOS 小工具,列出当前被非系统进程占用的监听端口,并支持一键或双击解除占用。

PortList 运行截图

功能

  • 🔍 自动扫描:启动时自动列出本机正在监听的 TCP 端口。
  • 🧹 智能筛选:左侧边栏按「全部端口 / 非系统端口 / 系统端口 / 协议(TCP / UDP)」分组,每组显示实时数量。
  • 🃏 可点击统计卡片:顶部「监听端口 / 非系统 / 系统」三张卡片可点击,作为筛选器,与侧栏选中状态联动。
  • 🚫 一键 / 双击解除占用:点击行内「解除占用」按钮,或双击任意一行,即可解除该端口占用;操作前会弹出确认框。
  • 🔎 实时搜索:按端口号、进程名或可执行路径即时过滤。
  • 📂 进程详情:每行显示端口、协议、地址、进程名、PID,以及进程启动程序路径(如 /usr/local/bin/node)。
  • 🔄 刷新反馈:刷新按钮重新扫描系统,完成后弹出提示「已重新扫描,共 N 个端口占用」;其后方的 ? 按钮提供使用提示(双击快捷键说明)。
  • 🪟 原生 macOS 设计:基于 SwiftUI + AppKit,采用现代 Liquid Glass 玻璃效果,完整支持深色模式,无第三方依赖。
  • 🌐 多语言:界面提供简体中文English,默认跟随系统语言自动切换。

“非系统端口”是如何定义的

工具通过 lsof -iTCP -sTCP:LISTEN 读取监听端口,并用 ps 补充进程完整路径与所属用户,满足以下任一条件即判定为系统进程

  • 可执行路径位于 /System//usr/libexec//Library/Apple//usr/sbin//sbin/
  • 进程名属于已知系统守护进程(如 launchdmDNSResponderWindowServer);
  • root 运行且路径位于 Apple 系统目录。

默认情况下 lsof 仅返回当前用户自己的进程端口,天然符合“非系统端口”的诉求。可在侧栏查看系统端口(root 进程需相应权限才能解除)。

解除占用的原理

点击确认后,ProcessKiller 会:

  1. 发送 SIGTERMkill -TERM <pid>)优雅终止,等待最多约 1.5s;
  2. 若进程仍在,发送 SIGKILLkill -KILL <pid>)强制结束;
  3. 重新扫描刷新列表。

权限说明:应用以当前用户身份运行,只能终止自己拥有的进程。若要解除 root 系统进程占用的端口,需以 sudo 启动应用(不推荐,除非你明确知道在做什么)。

多语言

界面支持 简体中文English,默认跟随系统语言自动切换(在「系统设置 → 语言与地区」中调整)。翻译集中在 PortList/Localizable.xcstrings;新增语言只需在 Xcode 中为该目录添加本地化,无需改代码。

About

A native macOS utility that lists listening ports occupied by non-system processes and lets you release them with one click or a double-click.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages