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?
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.
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!
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.
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
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.
Regards,
AndrΓ©as
Very glad to hear it! And what a great thread for others to learn from, many thanks for all your work over there.