firebase-tools: firebase functions:shell - Port 5000 is not open, could not start functions emulator
[REQUIRED] Environment info
firebase-tools: 7.2.2
Platform: macOS
[REQUIRED] Test case
firebase functions:shell
[REQUIRED] Steps to reproduce
$ npm install -g firebase-tools
$ npm install firebase-functions@latest firebase-admin@latest --save
firebase functions:shell
[REQUIRED] Expected behavior
firebase shell runs as advertised
[REQUIRED] Actual behavior
CLI Output: Port 5000 is not open, could not start functions emulator.
firebase-debug.log
[debug] [2019-08-18T03:02:45.322Z] ----------------------------------------------------------------------
[debug] [2019-08-18T03:02:45.324Z] Command: /usr/local/bin/node /usr/local/bin/firebase functions:shell
[debug] [2019-08-18T03:02:45.324Z] CLI Version: 7.2.2
[debug] [2019-08-18T03:02:45.324Z] Platform: darwin
[debug] [2019-08-18T03:02:45.324Z] Node Version: v10.15.3
[debug] [2019-08-18T03:02:45.330Z] Time: Sat Aug 17 2019 23:02:45 GMT-0400 (Eastern Daylight Time)
[debug] [2019-08-18T03:02:45.330Z] ----------------------------------------------------------------------
[debug]
[2019-08-18T03:04:19.141Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2019-08-18T03:04:19.141Z] > authorizing via signed-in user
[2019-08-18T03:04:19.142Z] [iam] checking project ddme-329f1 for permissions ["firebase.projects.get"]
[2019-08-18T03:04:19.143Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/ddme-329f1:testIamPermissions
permissions=[firebase.projects.get]
[2019-08-18T03:04:24.132Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Sun, 18 Aug 2019 03:04:23 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, server-timing=gfet4t7; dur=111, alt-svc=quic=":443"; ma=2592000; v="46,43,39", accept-ranges=none, transfer-encoding=chunked
Error: Port 5000 is not open, could not start functions emulator.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 16
- Comments: 24 (3 by maintainers)
Links to this issue
Commits related to this issue
- Pin portfinder@1.0.21. Fix #1606. — committed to firebase/firebase-tools by yuchenshi 5 years ago
- Update portfinder@1.0.23. Fix #1606. (#1608) * Pin portfinder@1.0.21. Fix #1606. * portfinder 1.0.23 should come with the fix. * Update package-lock.json. — committed to firebase/firebase-tools by yuchenshi 5 years ago
Seems to be related to the new portfinder release. https://github.com/http-party/node-portfinder/issues/84
The code used by the emulator fails with the latest version (1.0.22):
A workaround could be (besides using the old 1.0.21 version) :
QuickFix Edit the file
firebase-tools/lib/emulator/controller.js
in node_modules and changeyield pf.getPortPromise({ port, stopPort: port })
toyield pf.getPortPromise({ port, stopPort: port + 1 })
There is an open pull request which fixes this “bug”: https://github.com/http-party/node-portfinder/pull/86
In case someone want to find global
node_modules
to apply the quick fix. you can runnpm root -g
to see where your globalnode_modules
are.Thanks everyone for the discussion. As we’ve noticed, this is caused by a breaking change in portfinder and now fixed by https://www.npmjs.com/package/portfinder/v/1.0.23 . If you’re interested in how and why this broke us, see https://github.com/http-party/node-portfinder/issues/89
A clean install / update like
npm install -g firebase-tools@latest
should fix the issue.Combining both @micksatana and @lookfirst ideas together into the true one liner.
YMMV.
@Hacksore Only if you’ve installed firebase-tools globally, which is something I personally try to avoid with npm packages. I’d rather go with any alias in my .bashrc file:
export PATH="${PATH}:./node_modules/.bin"
Or just always use
npm run firebase
which addsnode_modules/.bin
to your path.The reason I avoid this is because this allows me to have different versions of dependencies in each project. If I decide I never want to use firebase again, I just remove the projects and I don’t have to remember to remove anything globally. I also don’t have version conflicts and strange behaviour this way.
Yes, the cost is more disk space, but disk is cheap.
Thanks for your kind help, I able to find it. Windows location for firebase-tools is: *C:\Users[user]\AppData\Roaming\npm\node_modules\firebase-tools*
I can confirm the QuickFix is working for me.
Firebase Tools: 7.2.2 Node: 12.8.1 OS: Fedora 30 Workstation
@akildemir There is no need to apply the quick fix. You can just upgrade the global module.
I found that updating the global
firebase-tools
package to the latest version (7.2.4) fixed the issue for meIf you are facing this issue in macOS Pro then this solution is for you.
In MacOS , Port 5000 may be claimed by a new “AirPlay Receiver”. This can be disabled in Settings -> Sharing:
I’m also adding the Screenshot of settings panel for disabling AirPlay Receiver.
Disabling the AirPlay Receiver (if you do not need it) frees up port 5000.
One line fix on OSX:
sed -i '' 's/stopPort: port/stopPort: port+1/' node_modules/firebase-tools/lib/emulator/controller.js