All jobs / DevOps / SRE / cloud / Linux
DevOps / SRE / cloud interview question · 1–3 years
A service fails to start with “address already in use” on port 8080. How do you find out what holds it?
The strongest answer
`ss -ltnp` (or `lsof -i :8080`) shows the listening socket and the owning PID; then I decide whether it is a stale copy of the same service or something that belongs there
Why it works
Right — the socket table tells you exactly who listens; guessing from process names does not.
What a good answer covers
- Ask the socket table, not the process list.
- ss -ltnp or lsof -i :port.
- Identify before you kill.
- Do not reboot to avoid looking.
Answers that fall short
- Close, but not the strongest: `ps aux | grep java` and kill whatever looks like an old instance
You are guessing by name; it may be a different service that legitimately owns the port. - Weak: Reboot the box; whatever it was will be gone
A reboot destroys the evidence and takes down everything else on the host for one port. - Red flag: Start the service as root so it can take the port over
Root does not seize a bound port, and running services as root to “fix” errors is a habit interviewers flag.
Who gets asked this
More Linux questions
- A runbook installs a CLI on every server with `curl https://… | sudo bash`. What do you prefer, and why?
- A deploy script failed on step two (the build), carried on, and pushed an empty artifact to production. What…
- `df -h` says the root volume is 100% full. `du -sh /` adds up to less than half of that. What is going on…
- Load average is 40 on an eight-core VM, yet `top` shows CPU mostly idle and the app is crawling. What does…
- `./deploy.sh` says “Permission denied” and `ls -l` shows `-rw-r--r--`. What do you do?
- What do you check, and what was the likely mistake?
- Everyone SSHes as root with the same key. What do you change first?