متقدم
البحث فيأدلة «كيف»
طريقة البحث
  • اكتب المهمة بكلماتك (find port، open firewall، disk full) أو الصق رسالة الخطأ بين علامتي تنصيص.
  • اختر «الإجابة السريعة» لترى الأوامر فقط، أو مجالًا لتبقى في مجال واحد.
  • "كلمتان" تجد العبارة بالضبط.
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث
جرّب:

كيف 1Network · Linux

How to find which process uses a port

"Address already in use", a web server that will not start, or an unknown open port in a security scan — every time, the first question is: which program is listening on this port? On Linux, ss answers it in one line. This how-to shows the quick answer, how to read the output, how to find the service or container behind the process, and what to do next.

  • 5 الدروس
  • 13 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

1.1

The quick answer

Replace 8080 with your port. Run as root (with sudo), or you will not see the process names of other users:

ss -ltnp 'sport = :8080'
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),("nginx",pid=1431,fd=6))
lsof -i :8080
fuser -v 8080/tcp

Here the answer is nginx, process IDs 1431 and 1432. For UDP ports use ss -lunp 'sport = :53'.

1.2

Step by step

  1. List every listening port with its program — a good overview first:
ss -ltnup
OptionMeaning
-lOnly listening sockets (servers).
-t / -uTCP / UDP.
-nShow numbers (port 443), not names (https) — faster and clearer.
-pShow the process (needs root for other users' processes).
  1. Read the Local Address column. 0.0.0.0:8080 or *:8080 = open on all network cards. 127.0.0.1:8080 = only from this server. [::]:8080 = IPv6 (often also IPv4).
  2. Find out what the process is — its full command and which systemd service started it:
ps -o pid,user,etime,cmd -p 1431
systemctl status 1431
● nginx.service - The nginx HTTP and reverse proxy server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled)
     Active: active (running) since Mon 2026-11-17 08:12:01 +03; 2h ago

systemctl status PID shows the unit that owns the process — now you know which service to stop, restart or reconfigure.

  1. Is it a container? If the process is docker-proxy, conmon, rootlessport or containerd, a container published the port:
docker ps --filter publish=8080
docker port web
podman ps --format '{{.Names}} {{.Ports}}'
kubectl get svc -A | grep 30080
  1. Decide what to do: stop or disable the other service (systemctl disable --now NAME), change the port of one of the two programs, or bind your app to 127.0.0.1 if only a local proxy needs it.

On RHEL and Ubuntu, ss is always installed (package iproute/iproute2). lsof may need dnf install lsof / apt install lsof. The old netstat -tlnp (package net-tools) still works but is no longer installed by default.

1.3

Check that it worked

After you stopped or moved the other program, the port must be free — then start yours and check again:

ss -ltnp 'sport = :8080'
State   Recv-Q  Send-Q  Local Address:Port  Peer Address:Port  Process
systemctl restart myapp
ss -ltnp 'sport = :8080'
curl -I http://127.0.0.1:8080

1.4

Common problems

ProblemCauseFix
The Process column is emptyYou are not root.Run with sudo.
The port shows nothing, but the app says "Address already in use"Another IP/IPv6 binding, or the port was busy only a moment (TIME_WAIT).Check ss -ltnp without a filter; wait a few seconds; set SO_REUSEADDR in your app.
The process is systemd (PID 1)Socket activation: systemd listens and starts the service on the first connection (for example ssh.socket, cockpit.socket).systemctl list-sockets; stop/disable the .socket unit.
The process is docker-proxyA container published the port.docker ps --filter publish=PORT; stop it or change -p.
The port is listening, but other hosts can not connectBound to 127.0.0.1, or the firewall blocks it.Check the Local Address; open the port: see "How to open a port in the firewall".
A custom port does not start on RHEL: Permission deniedSELinux allows a service only its known ports.semanage port -a -t http_port_t -p tcp 8081 (type depends on the service).

1.5

Go further

1Why does ss -ltnp show no process names for some ports?

You are not root; only root may see other users' processes. Use sudo.

2The listening process is systemd. What does that mean?

Socket activation — a .socket unit holds the port and starts the service on demand.

كل الأوامر في هذا الفصل