question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

firestore emulator on wsl2 does not work, results in ERR_CONNECTION_REFUSED

See original GitHub issue

[REQUIRED] Environment info

firebase-tools:8.4.1

Platform: wsl2 with Ubuntu-18.04

[REQUIRED] Test case

Start emulator firebase emulators:start --only firestore Navigate to http://127.0.0.1:4000/firestore Try to write in the database or simply check console

[REQUIRED] Steps to reproduce

Brand new project firebase init Select emulators and firestore firebase init to get firestore files firestore.rules firestore.indexes.json Follow test case above - go to url and write to database

[REQUIRED] Expected behavior

Should be able to write and read collection through emulator UI

[REQUIRED] Actual behavior

No changes are made to firestore, and receive error in console

xhrio.js:622 POST http://localhost:8080/google.firestore.v1.Firestore/Write/channel?database=projects%2Fmyproj%2Fdatabases%2F(default)&VER=8&RID=78563&CVER=22&X-HTTP-Session-Id=gsessionid&%24httpHeaders=Authorization%3ABearer%20owner%0D%0AX-Goog-Api-Client%3Agl-js%2F%20fire%2F7.14.3%0D%0A&zx=u51ejgj9v8vq&t=1 net::ERR_CONNECTION_REFUSED
firebase emulators:start --only firestore --debug
[2020-06-05T19:52:33.335Z] > 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"]
[2020-06-05T19:52:33.336Z] > authorizing via signed-in user
i  emulators: Starting emulators: firestore {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: firestore"}}
[2020-06-05T19:52:33.350Z] [hub] writing locator at /tmp/hub-leotestproj2.json
[2020-06-05T19:52:33.372Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: projectId"}}
[2020-06-05T19:52:33.372Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[2020-06-05T19:52:33.372Z] Starting Firestore Emulator with command {"binary":"java","args":["-Duser.language=en","-jar","/home/leo/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.4.jar","--host","localhost","--port",8080,"--rules","/home/leo/projects/practice/firebase-proj/firestore.rules"],"optionalArgs":["port","webchannel_port","host","rules","functions_emulator","seed_from_export"],"joinArgs":false} {"metadata":{"emulator":{"name":"firestore"},"message":"Starting Firestore Emulator with command {\"binary\":\"java\",\"args\":[\"-Duser.language=en\",\"-jar\",\"/home/leo/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.4.jar\",\"--host\",\"localhost\",\"--port\",8080,\"--rules\",\"/home/leo/projects/practice/firebase-proj/firestore.rules\"],\"optionalArgs\":[\"port\",\"webchannel_port\",\"host\",\"rules\",\"functions_emulator\",\"seed_from_export\"],\"joinArgs\":false}"}}
i  firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \u001b[1mfirestore-debug.log\u001b[22m"}}
[2020-06-05T19:52:33.966Z] API endpoint: http://localhost:8080 {"metadata":{"emulator":{"name":"firestore"},"message":"API endpoint: http://localhost:8080"}}
[2020-06-05T19:52:33.966Z] 
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.

 {"metadata":{"emulator":{"name":"firestore"},"message":"\nIf you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:\n\n   export FIRESTORE_EMULATOR_HOST=localhost:8080\n\nDev App Server is now running.\n\n"}}
[2020-06-05T19:52:34.138Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: auto_download"}}
[2020-06-05T19:52:34.138Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: port"}}
[2020-06-05T19:52:34.138Z] Starting Emulator UI with command {"binary":"node","args":["/home/leo/.cache/firebase/emulators/ui-v1.0.0/server.bundle.js"],"optionalArgs":[],"joinArgs":false} {"metadata":{"emulator":{"name":"ui"},"message":"Starting Emulator UI with command {\"binary\":\"node\",\"args\":[\"/home/leo/.cache/firebase/emulators/ui-v1.0.0/server.bundle.js\"],\"optionalArgs\":[],\"joinArgs\":false}"}}
i  ui: Emulator UI logging to ui-debug.log {"metadata":{"emulator":{"name":"ui"},"message":"Emulator UI logging to \u001b[1mui-debug.log\u001b[22m"}}
[2020-06-05T19:52:34.254Z] Web / API server started at http://localhost:4000
 {"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at http://localhost:4000\n"}}

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ βœ”  All emulators ready! View status and logs at http://localhost:4000 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Emulator  β”‚ Host:Port      β”‚ View in Emulator UI             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Firestore β”‚ localhost:8080 β”‚ http://localhost:4000/firestore β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  Other reserved ports: 4400, 4500

Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.

Note: I tried this on mac and it worked fine

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
yuchenshicommented, Jun 10, 2020

I see two issues here:

  1. Firestore emulator does not respond to 127.0.0.1 when asked to listen on localhost / 127.0.0.1 on WSL.
    • This may be an issue with WSL and much harder to troubleshoot.
  2. Emulator UI tries to construct an invalid URL like http://0.0.0.0:8080 when Firestore emulator is configured to listen on 0.0.0.0.

Hopefully fixing 2. can give you a reasonable workaround, and we’d appreciate any help on root-causing or working around 1.

2reactions
LeoTheGcommented, Jun 9, 2020

Thanks @yuchenshi , setting the host to 0.0.0.0 worked to be able to visit the emulator through my inet address. However I’m still unable to edit the firestore through the UI, this error appears now:

POST http://0.0.0.0:8080/google.firestore.v1.Firestore/Write/channel?database=projects%2Fmyproj%2Fdatabases%2F(default)&VER=8&RID=57465&CVER=22&X-HTTP-Session-Id=gsessionid&%24httpHeaders=Authorization%3ABearer%20owner%0D%0AX-Goog-Api-Client%3Agl-js%2F%20fire%2F7.14.3%0D%0A&zx=ymxr29oj2iv5&t=1 net::ERR_ADDRESS_INVALID
Read more comments on GitHub >

github_iconTop Results From Across the Web

Firestore emulator on wsl2 does not work, results in ...
WSL 2 is the only platform where firebase emulator is not working properly. I don't know where is the problem. I think that...
Read more >
Connect your app to the Cloud Firestore Emulator - Firebase
For any products you are not emulating, your apps and code will interact with the live resource (database instance, storage bucket, function, etc.)....
Read more >
Using ancestorInheritedElementForWidgetOfExactType in ...
You have to cast widget first: final inheritedWidget = context.ancestorInheritedElementForWidgetOfExactType(MyInheritedWidget).widget as MyInheritedWidget;.
Read more >
Firestore/Firebase Emulator Not Running
I had the same issue there were a few things wrong for me. ensure the emulator is installed by running firebase setup:emulators:firestore.
Read more >
how to install express in console Code Example
OperationalError: could not connect to server: Connection refused Is the ... WSL2 trying to launch VSCode with code . results in error "Please...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found