Process Monitoring — Find It, Inspect It, Signal It
You restart notes-api and it refuses to start: "address already in use". Something is still holding port 8000. To fix it you need to find that process, understand what it is, and stop it without making things worse.
The rule
Every running program is a process with a PID: find it, inspect it, signal it.
The kernel gives every running program a process ID (PID). The tools you need:
ps aux # every process, with user, CPU, memory, command
pgrep -af notes-api # PIDs and full command lines matching a pattern
top # live view, busiest first (htop is a friendlier version)
sudo lsof -i :8000 # which process has port 8000 open
sudo ss -ltnp # every listening TCP port and its process
systemctl status notes-api # a systemd service's state, PID and last log lines
journalctl -u notes-api -n 50 # the service's recent logTo stop a process you send it a signal with kill:
kill 4312sends SIGTERM (15), the default: "please shut down". The program can finish requests, flush files and exit cleanly.kill -9 4312sends SIGKILL: the kernel ends it immediately. No clean-up, open work is lost.kill -HUP(SIGHUP) asks many daemons, such as nginx, to reload their configuration.
If the process belongs to a systemd service, stop it with systemctl stop instead, or systemd may simply start it again.