Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hosting emulator defaults to a port that's not open by default in macOS Monterey #3875

Closed
HaydenBL opened this issue Oct 29, 2021 · 10 comments
Closed

Comments

@HaydenBL
Copy link

[REQUIRED] Environment info

firebase-tools: 9.21.9

Platform: macOS 12.0.1 Monterey, MacBook Pro (14-inch, 2021)

[REQUIRED] Test case

$ yarn start
yarn run v1.22.17
$ firebase emulators:start
i  emulators: Starting emulators: functions, hosting
⚠  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, firestore, database, pubsub, storage
✔  functions: Using node@12 from host.
⚠  functions: Unable to fetch project Admin SDK configuration, Admin SDK behavior in Cloud Functions emulator may be incorrect.
i  emulators: Shutting down emulators.
i  functions: Stopping Functions Emulator
i  hub: Stopping emulator hub
⚠  hosting: Port 5000 is not open on localhost, could not start Hosting Emulator.
⚠  hosting: To select a different host/port, specify that host/port in a firebase.json config file:
      {
        // ...
        "emulators": {
          "hosting": {
            "host": "HOST",
            "port": "PORT"
          }
        }
      }
i  emulators: Shutting down emulators.

Error: Could not start Hosting Emulator, port taken.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

[REQUIRED] Steps to reproduce

  1. Use macOS Monterey
  2. Install firebase-tools
  3. Try starting emulators in a firebase project: firebase emulators:start
  4. Error because port is already used

It seems as if this is an issue because the new version of macOS has an "AirPlay receiver" feature which allows you to AirPlay to a Mac device, and this listens on port 5000. Obviously this can be worked around by disabling the feature or changing the emulator hosting port in the firebase config, but the feature comes on by default so I imagine a lot of people will be running into this as they upgrade to the latest OS.

[REQUIRED] Expected behavior

Emulator should start without having to disable AirPlay receiver or changing the default port.

[REQUIRED] Actual behavior

The firebase hosting emulator won't start until you disable AirPlay receiver, or the hosting port.

@momander
Copy link

Thanks for tracking this down and reporting it!

Folks like me who aren't interested in AirPlay can turn it off from System Preferences, Sharing, and then uncheck the checkbox titled "AirPlay receiver". Then Firebase hosting on port 5000 works again.

@abeisgoat
Copy link
Contributor

Hmm, that is really annoying. Since we've set the precedent of using port 5000 for most of a decade I would be inclined to simply provide a better error if we encounter a port conflict on Monterey.

@jessejiang0214
Copy link

Hi Team,

I got this error when I start the emulators on Monterey, it was working on BigSir

INFO: Started WebSocket server on ws://localhost:53599
API endpoint: http://localhost:8080
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:

   export FIRESTORE_EMULATOR_HOST=localhost:8080

Dev App Server is now running.

*** shutting down gRPC server since JVM is shutting down
*** server shut down

I found a solution to change the firebase.json, like

"emulators": {
    "firestore": {
      "host": "0.0.0.0",
      "port": "8080"
    }
  }

It can launch the emulator, but the callback function is not working, like firestore callback when an object is added.

Any idea on this?

Thanks
Jesse

@v1ct0r
Copy link

v1ct0r commented Nov 11, 2021

"host": "0.0.0.0",

@jessejiang0214, you saved my day!

@jessejiang0214
Copy link

Hi @v1ct0r change host just can launch the emulator, but the callback function for the emulator is not working.

@reyesdf
Copy link

reyesdf commented Nov 15, 2021

Thanks for tracking this down and reporting it!

Folks like me who aren't interested in AirPlay can turn it off from System Preferences, Sharing, and then uncheck the checkbox titled "AirPlay receiver". Then Firebase hosting on port 5000 works again.

This worked. thank you very much!

@eewindfly
Copy link

Hi Team,

I got this error when I start the emulators on Monterey, it was working on BigSir

INFO: Started WebSocket server on ws://localhost:53599
API endpoint: http://localhost:8080
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:

   export FIRESTORE_EMULATOR_HOST=localhost:8080

Dev App Server is now running.

*** shutting down gRPC server since JVM is shutting down
*** server shut down

I found a solution to change the firebase.json, like

"emulators": {
    "firestore": {
      "host": "0.0.0.0",
      "port": "8080"
    }
  }

It can launch the emulator, but the callback function is not working, like firestore callback when an object is added.

Any idea on this?

Thanks Jesse

I have similar log, but change host to 0.0.0.0 still didn't work for me.
Finally I figured out it was JAVA-related issue.
So simply "brew uninstall java; brew install java" works!!

@weixifan
Copy link

I've created an internal bug b/211308357 to track this issue. As @abeisgoat mentioned, improving the error message might be the resolution here.

@grantkemp
Copy link

Potential Workaround - for those who just want to run hosting locally - there is a port flag on the serve command you can use:
firebase serve --port 5050 worked for me to force hosting to use port 5050.

@yuchenshi yuchenshi assigned bkendall and unassigned abeisgoat Feb 28, 2022
@jamesdaniels
Copy link
Member

Fixed in #4415

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests