# Rails “A server is already running”? Fix it Source: https://portlivo.com/guides/rails-server-already-running · Updated 2026-12-04 You run bin/rails server and Rails stops before it starts, pointing at tmp/pids/server.pid. Either an old server really is still running, or the file names a process ID that now belongs to something else. A minute with ps tells you which. **In short:** Run `ps -o pid,command -p ` with the PID from the message. If it’s Puma or `rails server` from this project, stop it with `kill `. If it’s anything else, or nothing, the file is stale: `rm tmp/pids/server.pid` and start again. In Docker, delete the file before the server starts, in the container’s start command. ## The error ``` A server is already running (pid: 48211, file: /Users/you/code/shop/tmp/pids/server.pid). Exiting ``` In development Rails writes its process ID to `tmp/pids/server.pid` and deletes the file when it exits. On start, it reads the file and asks macOS whether that process exists. If the process is gone, Rails deletes the file itself and starts. It only refuses when some process with that ID is still alive. ## 1. See what that PID is ``` ps -o pid,etime,command -p 48211 ``` | ps shows | What it means | Do this | | --- | --- | --- | | `puma …` or `rails server` from this project | The old server is still running, maybe in another tab or left behind by a closed one | `kill 48211`, or switch to the tab and press Ctrl-C | | Any other program | The PID was reused after a restart: the file is stale | `rm tmp/pids/server.pid` | | Nothing (no rows) | Rare: the process ended between the check and now | Start the server again | > macOS reuses process IDs after a restart, so a file left by a crash can point at Safari or a system process. Never kill the PID from the file without checking what it is first. ## 2. Stop the old server, or remove the file ``` kill 48211 # if ps showed Puma rm tmp/pids/server.pid # if it didn’t bin/rails server ``` `kill` sends a normal stop, so Puma shuts down and removes its own file. If it’s still there after a few seconds, `kill -9 48211` ends it, and then you delete the file by hand. ## Then: “Address already in use” on port 3000 Get past the pid file and Puma may stop at the port instead: `Address already in use - bind(2) for "127.0.0.1" port 3000`. Something else holds 3000, often another project’s server. Find it: ``` lsof -nP -iTCP:3000 -sTCP:LISTEN ``` Stop it, or run this one elsewhere with `bin/rails server -p 3001`. More in [port already in use on Mac](https://portlivo.com/guides/port-already-in-use-mac). ## In Docker: it happens on every start When the app folder is mounted into the container, `tmp/pids/server.pid` survives a stopped container. The next start finds it, and inside a fresh container that low PID often belongs to a live process, so Rails refuses every time. Delete the file as part of the start command: ``` command: bash -c "rm -f tmp/pids/server.pid && bin/rails server -b 0.0.0.0" ``` Or write the file somewhere that isn’t mounted: `bin/rails server -P /tmp/server.pid`. ## Running two servers on purpose Two servers from one project folder (say, a second one on another port) clash over the same pid file. Give the second its own file and port: ``` bin/rails server -p 3001 -P tmp/pids/server-3001.pid ``` ## The one-click way: Portlivo Portlivo shows every running Rails server in the menu bar with its project folder, port and how long it’s been up, so the one a closed tab left behind is easy to spot. Stop it there and Puma exits cleanly, removing its own pid file. Start the project from Portlivo and it finds `bin/dev` or `bin/rails server` on its own. If port 3000 is taken, it says by what and offers **Kill Holder & Retry**. ## Questions people ask **Is it safe to delete tmp/pids/server.pid?** Yes, once you’ve checked that the PID in it isn’t a running Rails server. The file only tells Rails a server was running; it holds no data. **Why does Rails say a server is running when none is?** The file is left over from a crash or a forced restart, and its PID now belongs to another process. Rails can’t tell the difference, so it refuses. Delete the file. **Does this happen with bin/dev?** Yes. `bin/dev` runs `bin/rails server`, on its own or through Foreman, so the same pid file applies. Closing the terminal without Ctrl-C can leave the server running.