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:
- Created 3 years ago
- Reactions:1
- Comments:17 (10 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I see two issues here:
127.0.0.1
when asked to listen onlocalhost
/127.0.0.1
on WSL.http://0.0.0.0:8080
when Firestore emulator is configured to listen on0.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.
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: