/dev-server [start|stop|status]
Manage the Next.js development server on port 3000.
Arguments
- •
start(default) — Start the dev server if not already running - •
stop— Stop the running dev server - •
status— Check if the server is running
Instructions
For status or no argument default check:
- •Run
lsof -ti:3000to check if anything is listening on port 3000 - •If a PID is found, report: "Dev server is running (PID: <pid>)"
- •If no PID, report: "Dev server is not running"
For start:
- •First check if port 3000 is already in use with
lsof -ti:3000 - •If already running, report it and do nothing
- •If not running, start the server with
npm run devin the background - •Wait a few seconds, then verify it started by checking port 3000 again
- •Report the result
For stop:
- •Find the PID with
lsof -ti:3000 - •If found, kill it with
kill <pid> - •Verify it stopped
- •If no server is running, report "No dev server to stop"
Notes
- •The dev server runs on port 3000 by default
- •Use
npm run devto start (runsnext dev) - •The server should be started in the background so it doesn't block the terminal