Netlify Dev Port command not working?

I had a netlify dev server running on a site in one tab and fired up another to test something. I noticed it used the same port as the first site, and on checking the docs saw that I could specify a port. So I then tried: netlify dev -p 4001 and the -p was ignored, as far as I could see. Should that have worked?

1 Like

Same thing is happening for me. --port is ignored.

I tried killing all processes on the port I specified, but it didn’t help.

Hey guys, sorry for the confusion, it does seem like the port flag and its use was conflicting. But with the latest version of netlify-cli, you can run multiple instances of netlify dev without specifying port because it tries to get the original port but reverts to a random one if that is not available. They do have to be different kinds of projects, for example, you cannot run multiple instances of netlify dev for create-react-app projects because all create-react-app instances will use port 3000.
In the mean time, working on a fix, perhaps more descriptive flag names.

1 Like

Hi it’s been 8 months since this was brought up and it seems like the latest version of Netlify CLI still lists support for the -p/–port option but continues to just run on port 8888. We need a consistent port for OAuth redirects and have been using port 9000 everywhere else. I’d love to be able to just keep using port 9000, but it seems like there’s no support for that? Is the plan to not ever support consistent ports, and we should just be hoping that port 8888 is used every time?

Apologies for the confusion around this. We’ve just released a new version of the CLI which includes changes regarding this. In the latest version netlify dev will try to acquire the port specified by -p/--port options and throw and error if that isn’t available. If an option is not specified in the flags or in config file, it will try to acquire a preferred port and fallback to a random one if that isn’t available.
Please make sure to update your Netlify CLI via npm i -g netlify-cli@latest to use this feature.

I just upgraded to netlify-cli@latest (2.40.0). I’m running with the following setting in my [dev] block in netlify.toml

port = 9000

and the following command

netlify dev -p 9000

The dev server still starts on port 8888.

Can you upgrade to netlify-cli@2.41.0 and try that again please!

1 Like

I’ve got a simple static site setup:
When I run

 npx netlify-cli@2.40.0 dev -p 9000

I get the following message:

β—ˆ Netlify Dev β—ˆ
β—ˆ No dev server detected, using simple static server
Waiting for localhost:3999.
β—ˆ Server listening to 3999

Connected!
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                                                 β”‚
β”‚   β—ˆ Server now ready on http://localhost:8888   β”‚
β”‚                                                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The site launches on port 8888.

When I run

npx netlify-cli@2.41.0 dev -p 9000

I get the following:

β—ˆ Netlify Dev β—ˆ
β—ˆ No dev server detected, using simple static server
Waiting for localhost:3999.
β—ˆ Server listening to 3999

Connected!
Waiting for localhost:34567.............................................................

The Process just hangs there forever.

Also I’m able to launch other sites that run on port 9000, so it’s not that the port is in use.

@cpardy That’s an odd behavior. Can you try pkill node and run netlify dev -p 9000 again and see if that fixes it

It’s still not working. I installed netlify-cli locally so I can take npx as an issue off the table.
The same exact behavior it’s ignoring the β€œ-p” flag and consistently using port 34567.

1 Like

I have the same behaviour: -p < any numbers > gives the only port:34567

PS C:\Users.…***nuxt> netlify dev -p 9000
β—ˆ Netlify Dev β—ˆ
β—ˆ Starting Netlify Dev with nuxt
Waiting for localhost:3000…
Connected!
Waiting for localhost:34567…

vanirn, can you confirm that you upgraded to 2.41.0 and are still seeing this error? thanks!

Yes!
VERSION
netlify-cli/2.41.0 win32-x64 node-v12.13.0
But with a [Dev] configuration in netlify.toml the port is changing.

@Vanirn this was indeed an issue. A fix will be released soon: Dev: Don't wait on functions port if no server by RaeesBhatti Β· Pull Request #803 Β· netlify/cli Β· GitHub

A fix for this has been released in netlify-cli@2.42.0 . Please update and let us know if it is still an issue.

I have this same problem when using the --live flagβ€”it works fine without it. I’m using a Gatsby site and have version 2.46 of the netlify-cli installed

Hello everybody :wave:

Any update on the issue?

In my case, installing netlify-cli@2.59.0 and running netlify dev -p 3000 didn’t solve the issue.

Thanks

Hey @mcyouks,
Could you share any error message you saw? Also wanted to share this issue in case it’s clarifying or you wanted to chime in there:

Hello @jen,

After deeper research, I realized that my issue was slightly different than this one. Everything has been explained and solved on this thread. :white_check_mark:

Regards,
AndrΓ©as

1 Like

Very glad to hear it! And what a great thread for others to learn from, many thanks for all your work over there.

1 Like