Error running yarn dev: Port 3000 already in use (but it's not)

Environment Details

  • Node version: v18.20.2
  • Yarn version: 1.22.19
  • macOS version: 14.6.1
  • Ghost version: 5.96.2 (inferred from package versions in the error log)

Issue Description

I’m trying to set up the Ghost CMS project locally to contribute, but I’m encountering an error when running yarn dev. The error suggests that port 3000 is already in use, but I’ve verified that it’s not.

Steps Taken

  1. Followed the setup guide provided in the project documentation.
  2. Ran yarn dev to start the development environment.
  3. Encountered an error stating “Port 3000 is already in use.”
  4. Checked for processes using port 3000 with:
  • sudo lsof -i:3000
  • netstat -an | grep 3000 Both commands confirmed that no processes were using port 3000.

Error Output

[> admin] Port 3000 is already in use.
> [admin] npm ERR! Lifecycle script `dev` failed with error: 
> [admin] npm ERR! Error: command failed 
> [admin] npm ERR!   in workspace: ghost-admin@5.96.2 
> [admin] npm ERR!   at location: /Users/subhapradachand/Code/Ghost/ghost/admin

I also got this warning:

WARNING: Node v18.20.2 is not tested against Ember CLI on your platform. We recommend that you use the most-recent "Active LTS" version of Node.js.

i had received a same warning when using node v20, so i don’t know if this is the cause.

Full error logs:

yarn dev

**yarn run v1.22.19**

$ node .github/scripts/dev.js

Running projects: ghost, ts, admin, adminXDeps, adminX

[admin]

[admin] > nx run ghost-admin:dev --live-reload-base-url=/ghost/ --live-reload-port=4201

[admin]

[adminX]

[adminX] **NX** Running target **dev** for 3 projects and **2** tasks they depend on:

[adminX]

[adminX] - @tryghost/admin-x-demo

[adminX] - @tryghost/admin-x-settings

[adminX] - @tryghost/admin-x-activitypub

[adminX]

[adminX]

[ghost]

[ghost] **NX** Running target **dev** for project ghost and **13** tasks it depends on:

[ghost]

[ghost]

[ghost]

[ghost] > nx run @tryghost/email-addresses:"build:ts" [local cache]

[ghost]

[ghost]

> nx run @tryghost/nql-filter-expansions:"build:ts" [local cache]

[ghost]

[ghost]

> nx run @tryghost/in-memory-repository:"build:ts" [local cache]

[ghost]

[ghost]

> nx run @tryghost/post-events:"build:ts" [local cache]

[ghost]

[ghost]

[ghost] > nx run @tryghost/bookshelf-repository:"build:ts" [local cache]

[ghost]

[ghost]

[ghost] > nx run @tryghost/post-revisions:"build:ts" [local cache]

[ghost]

[ghost]

[ghost] > nx run @tryghost/mail-events:"build:ts" [local cache]

[ghost]

[ghost]

[ghost] > nx run @tryghost/collections:"build:ts" [local cache]

[ghost]

[adminX]

[adminX] > nx run @tryghost/admin-x-design-system:build [local cache]

[adminX]

[adminX]

[adminX] > @tryghost/admin-x-design-system@0.0.0 build

[adminX] > tsc -p tsconfig.declaration.json && vite build

[adminX]

[ghost]

[ghost] > nx run @tryghost/recommendations:"build:ts" [local cache]

[ghost]

[ghost]

[ghost] > nx run @tryghost/metrics-server:"build:ts" [local cache]

[ghost]

[ghost]

[ghost] > nx run @tryghost/donations:"build:ts" [local cache]

[ghost]

[ghost]

[ghost] > nx run @tryghost/model-to-domain-event-interceptor:"build:ts" [local cache]

[ghost]

[ghost]

[ghost] > nx run @tryghost/ghost:"build:ts" [local cache]

[ghost]

[ghost]

[ghost] > nx run ghost:dev

[ghost]

[adminX]

[adminX] > nx run @tryghost/admin-x-framework:build [local cache]

[adminX]

[adminX]

[adminX] > @tryghost/admin-x-framework@0.0.0 build

[adminX] > tsc -p tsconfig.declaration.json && vite build

[adminX]

[adminX]

[adminX] > nx run @tryghost/admin-x-activitypub:dev

[adminX]

[adminX]

[adminX] > nx run @tryghost/admin-x-demo:dev

[adminX]

[adminX]

[adminX] > nx run @tryghost/admin-x-settings:dev

[adminX]

[admin] > ghost-admin@5.96.2 dev

[admin] > ember serve --live-reload-base-url=/ghost/ --live-reload-port=4201

[ghost] > ghost@5.96.2 dev

[ghost] > node --watch index.js

[adminX] > @tryghost/admin-x-demo@0.0.0 dev

[adminX] > vite build --watch

[adminX] > @tryghost/admin-x-activitypub@0.1.3 dev

[adminX] > vite build --watch

[adminX] > @tryghost/admin-x-settings@0.0.0 dev

[adminX] > vite build --watch

[ghost] (node:9521) ExperimentalWarning: Watch mode is an experimental feature and might change at any time

[ghost] (Use `node --trace-warnings ...` to show where the warning was created)

[ghost] [2024-10-18 15:37:26] INFO Ghost is running in development...

[ghost] [2024-10-18 15:37:26] INFO Listening on: 127.0.0.1:2368

[ghost] [2024-10-18 15:37:26] INFO Url configured as: <link tolocalhost:2368>

[ghost] [2024-10-18 15:37:26] INFO Ctrl+C to shut down

[ghost] [2024-10-18 15:37:26] INFO Ghost server started in 0.329s

[ghost] [2024-10-18 15:37:26] INFO Database is in a ready state.

[ghost] [2024-10-18 15:37:26] INFO Ghost database ready in 0.559s

[ghost] [2024-10-18 15:37:27] INFO Invalidating assets for regeneration

[ghost] [2024-10-18 15:37:27] INFO Adding offloaded job to the queue

[ghost] [2024-10-18 15:37:27] INFO Scheduling job mentions-email-report at 23 42 * * * *. Next run on: Fri Oct 18 2024 21:42:23 GMT+0530 (India Standard Time)

[ghost] [2024-10-18 15:37:27] INFO Adding offloaded job to the queue

[ghost] [2024-10-18 15:37:27] INFO Scheduling job clean-expired-comped at 57 20 5 * * *. Next run on: Sat Oct 19 2024 05:20:57 GMT+0530 (India Standard Time)

[ghost] [2024-10-18 15:37:27] INFO Adding offloaded job to the queue

[ghost] [2024-10-18 15:37:27] INFO Scheduling job clean-tokens at 2 59 18 * * *. Next run on: Sat Oct 19 2024 18:59:02 GMT+0530 (India Standard Time)

[ghost] [2024-10-18 15:37:27] INFO Ghost booted in 2.225s

[ghost] [2024-10-18 15:37:27] INFO Adding offloaded job to the queue

[ghost] [2024-10-18 15:37:27] INFO Scheduling job email-analytics-fetch-latest at 22 4/5 * * * *. Next run on: Fri Oct 18 2024 21:09:22 GMT+0530 (India Standard Time)

[ghost] [2024-10-18 15:37:27] INFO Adding offloaded job to the queue

[ghost] [2024-10-18 15:37:27] INFO Scheduling job update-check at 26 50 17 * * *. Next run on: Sat Oct 19 2024 17:50:26 GMT+0530 (India Standard Time)

[ghost] [2024-10-18 15:37:27] INFO Running milestone emails job on Fri Oct 18 2024 21:07:32 GMT+0530 (India Standard Time)

[ghost] [2024-10-18 15:37:28] INFO Ghost URL Service Ready in 2.462s

[admin] WARNING: Node v18.20.2 is not tested against Ember CLI on your platform. We recommend that you use the most-recent "Active LTS" version of Node.js. See:git.io/v7S5n for details.

[admin] Port 3000 is already in use.

[admin] npm ERR! Lifecycle script `dev` failed with error:

[admin] npm ERR! Error: command failed

[admin] npm ERR! in workspace: ghost-admin@5.96.2

[admin] npm ERR! at location: /Users/subhapradachand/Code/Ghost/ghost/admin

[admin]

[admin]

[admin]

[admin] **NX** Running target **dev** for project ghost-admin failed

[admin]

[admin] Failed tasks:

[admin]

[admin] - ghost-admin:dev

[admin]

[admin] Hint: run the command with --verbose for more details.

[admin]

[admin] nx run ghost-admin:dev --live-reload-base-url=/ghost/ --live-reload-port=4201 exited with code 1

--> Sending SIGTERM to other processes..

[ghost] [2024-10-18 15:37:29] WARN Ghost is shutting down

[ghost] [2024-10-18 15:37:29] WARN Ghost has shut down

[ghost] [2024-10-18 15:37:29] WARN Ghost was running for a few seconds

[adminX]

[adminX]

[adminX]

[adminX] **NX** Running target **dev** for 3 projects and **2** tasks they depend on failed

[adminX]

[adminX] Failed tasks:

[adminX]

[adminX] - @tryghost/admin-x-activitypub:dev

[adminX] - @tryghost/admin-x-demo:dev

[adminX] - @tryghost/admin-x-settings:dev

[adminX]

[adminX]

[adminX] **NX** Nx detected flaky tasks

[adminX]

[adminX] @tryghost/admin-x-design-system:build

[adminX] @tryghost/admin-x-framework:build

[adminX]

[adminX] Flaky tasks can disrupt your CI pipeline. Automatically retry them with Nx Cloud. Learn more at flaky_tasks_url

[adminX]

[adminX] nx run-many --projects=@tryghost/admin-x-demo,@tryghost/admin-x-settings,@tryghost/admin-x-activitypub --parallel=79 --targets=dev exited with code 1

--> Sending SIGTERM to other processes..

[ghost]

[ghost]

[ghost]

[ghost] **NX** Successfully ran target **dev** for project ghost and **13** tasks it depends on

[ghost]

[ghost] Nx read the output from the cache instead of running the command for 13 out of 14 tasks.

[ghost]

[ghost]

[ghost] **NX** Nx detected flaky tasks

[ghost]

[ghost] @tryghost/recommendations:build:ts

[ghost] @tryghost/metrics-server:build:ts

[ghost] @tryghost/model-to-domain-event-interceptor:build:ts

[ghost] @tryghost/ghost:build:ts

[ghost]

[ghost] Flaky tasks can disrupt your CI pipeline. Automatically retry them with Nx Cloud. Learn more at flaky_tasks_url

[ghost]

[ghost] nx run ghost:dev exited with code 0

--> Sending SIGTERM to other processes..

^C

[ts] while [ 1 ]; do nx watch --projects=ghost/bookshelf-repository,ghost/collections,ghost/donations,ghost/email-addresses,ghost/ghost,ghost/in-memory-repository,ghost/mail-events,ghost/metrics-server,ghost/model-to-domain-event-interceptor,ghost/nql-filter-expansions,ghost/post-events,ghost/post-revisions,ghost/recommendations -- nx run \$NX_PROJECT_NAME:build:ts; done exited with code SIGTERM

--> Sending SIGTERM to other processes..