Netlify dev --port=3002 crashes after init consistently

netlify dev crashes after init and says it could not acquire the port. I’ve tried changing the port and running netlify dev --port=PORT several times. same issue. I’m on the latest version of the netlify-cli.
can’t think of anything else - netlify.toml and package.json seem standard.

  • netlify site name: otto-writes.netlify.app
  • Build problems? Link or paste the FULL build log & build settings screenshot
    netlify dev
    (node:2531) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
    (Use node --trace-deprecation ... to show where the warning was created)
    ◈ Netlify Dev ◈
    ◈ Injecting environment variable values for all scopes
    ◈ Using simple static server because ‘[dev.framework]’ was set to ‘#static
    ◈ Running static server from “node-server/public”
    ◈ Setting up local development server
    Cleaned up .netlify/functions-internal.
    ◈ Static server listening to 3999
    ◈ Loaded function qna
    Request from ::1: GET /.netlify/functions/qna/0
    Parsed index: 0
    Response with status 200 in 32 ms.
    winston:create-logger: Define prototype method for “error”
    winston:create-logger: Define prototype method for “warn”
    winston:create-logger: Define prototype method for “info”
    winston:create-logger: Define prototype method for “http”
    winston:create-logger: Define prototype method for “verbose”
    winston:create-logger: Define prototype method for “debug”
    winston:create-logger: Define prototype method for “silly”
    winston:create-logger: Define prototype method for “error”
    winston:create-logger: Define prototype method for “warn”
    winston:create-logger: Define prototype method for “info”
    winston:create-logger: Define prototype method for “http”
    winston:create-logger: Define prototype method for “verbose”
    winston:create-logger: Define prototype method for “debug”
    winston:create-logger: Define prototype method for “silly”
    (node:2595) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
    (Use node --trace-deprecation ... to show where the warning was created)
    2024-04-05T22:05:26.300Z dev:preAction start
    2024-04-05T22:05:26.301Z dev:init start
    2024-04-05T22:05:27.795Z netlify:init end
    2024-04-05T22:05:27.795Z dev:preAction end
    ◈ Netlify Dev ◈
    ◈ Injecting environment variable values for all scopes
    ◈ Ignored general context env var: SITE_ID (defined in process)
    ◈ Ignored general context env var: SITE_NAME (defined in process)
    ◈ Ignored general context env var: DEPLOY_ID (defined in process)
    ◈ Using simple static server because ‘[dev.framework]’ was set to ‘#static
    ◈ Running static server from “node-server/public”
    ◈ Could not acquire required ‘port’: ‘3002’
    ◈ Command failed with exit code 1: npm run start. Shutting down Netlify Dev server

netlify.toml:

[build]
functions = “netlify/functions”
command = “npm run build”
publish = “public/”

[dev]
functions = “netlify/functions”
command = “npm run start”
publish = “public”
framework = “#static
publicPath = “public”
port = 3002

This explains why. Something is already using that port.

I did an lsof on the port before running netlify dev. The port was not in use.
to be certain I changed the port numbers, did an lsof, ran netlify dev
exact same behavior.

My env is

Environment

System:
Mac
Binaries:
Node: 18.19.0 - /usr/local/bin/node
npm: 10.4.0 - /usr/local/bin/npm
npmGlobalPackages:
netlify-cli: 17.17.0

Is there a specific reason you need/want Netlify dev to run on post 3002 instead of the standard 8888?

No specific reason for choosing port 3002; it was primarily to avoid conflicts with other services that might be running on more common ports like 8888. I’m flexible with the port configuration and am willing to use the standard 8888 port for Netlify Dev if that’s more stable or conventional.
My main goal is to ensure a stable local development environment, so I’m open to recommendations or best practices.

Does Netlify dev work on port 8888?

It does not. It unexpectedly terminates the cli

› Warning: Error: Netlify CLI has terminated unexpectedly
› This is a problem with the Netlify CLI, not with your application.
› If you recently updated the CLI, consider reverting to an older version by running:

› npm install -g netlify-cli@VERSION

› You can use any version from Releases · netlify/cli · GitHub.

› Please report this problem at Sign in to GitHub · GitHub including the error details below.

› at error (file:///opt/homebrew/lib/node_modules/netlify-cli/dist/utils/command-helpers.js:168:19)
› at process. (file:///opt/homebrew/lib/node_modules/netlify-cli/dist/commands/main.js:40:5)
› at process.emit (node:events:531:35)
› at processEmit (/opt/homebrew/lib/node_modules/netlify-cli/node_modules/signal-exit/index.js:199:34)
› at process.emit (/opt/homebrew/lib/node_modules/netlify-cli/node_modules/source-map-support/source-map-support.js:516:21)
› at process._fatalException (node:internal/process/execution:178:25)
› at processPromiseRejections (node:internal/process/promises:289:13)
› at processTicksAndRejections (node:internal/process/task_queues:96:32)
Error: EACCES: permission denied, rmdir ‘/Users/llama/Documents/ai-projects/node-server/.netlify/functions-serve/qna’

System:
OS: macOS 12.5.1
CPU: (10) arm64 Apple M1 Pro
Binaries:
Node: 21.5.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 10.2.4 - /opt/homebrew/bin/npm
Browsers:
Chrome: 123.0.6312.107
Safari: 15.6.1
npmGlobalPackages:
netlify-cli: 17.21.2

Then the issue is not isolated to port selection. You should do what it suggests below