Firebase-tools: Unable to deploy behind a proxy

Created on 26 May 2016  ·  151Comments  ·  Source: firebase/firebase-tools

Hi,

I'm following the firebase web tutorial (https://codelabs.developers.google.com/codelabs/firebase-web/).
Everything works fine for the 8 first steps, but in step 9 I have a problem : the command firebase deploy hangs indefinitely.
I have this behavior while being behind a proxy (http_proxy and https_proxy are set in the env).

Is there a way to deploy behind a proxy ?
This seems related to issue #36

Yann


Here is the output of firebase deploy --debug

----------------------------------------------------------------------
Command:      node /Users/ymainier/.nvm/versions/node/v0.12.1/bin/firebase deploy --debug
CLI Version:  3.0.0
Platform:     darwin
Node Version: v0.12.1
Time:         Wed May 25 2016 16:46:59 GMT+0200 (CEST)
----------------------------------------------------------------------

> command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"]
>>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/friendlychat-dd6a6 
<<< HTTP RESPONSE 200 server=nginx, date=Wed, 25 May 2016 14:47:57 GMT, content-type=application/json; charset=utf-8, content-length=124, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
>>> HTTP REQUEST GET https://admin.firebase.com/v1/database/friendlychat-dd6a6/tokens 
<<< HTTP RESPONSE 200 server=nginx, date=Wed, 25 May 2016 14:47:57 GMT, content-type=application/json; charset=utf-8, content-length=433, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
p2 bug

Most helpful comment

Firebase devs please solve this issue, it a serious dev delay up to date.

All 151 comments

This is a known issue. We'd like to figure out a workaround, but it may take some time. I'll leave the issue open to track.

I have the same problem, the firebase team just write me this:

"Not possible at the moment, tracking here: https://github.com/firebase/firebase-tools/issues/155 but no timeline on a fix."

Actually referring me to this page XP

Hope this will be fix soon, since many of us developers use this tools at work

I have the same problem. Makes it hard to eval firebase in many work environments. :( Also, I have a problem via my satellite inet at home (opening separate issue for that) :(_

Same Problem here ! Also this problem is there with all firebase functions on android except authentication.

Wel I managed to get it working on my work, but I just can't login,

I also tried doing the `firebase login --no-localhost but that gave just a Error: Authentication Error.

same problem ..

I've came to this problem twice ..

The timeout occurs when the Firebase node module makes a connection using faye-websockets, which does not make use of http_proxy and associated environment variables.

There is a comment on StackOverflow that describes how to hard-code the proxy config in faye-websockets as a work-around.

Not elegant, but at least I can deploy now :)

Same issue here. All the other firebase commands seem to work just fine. "firebase deploy" is the only one getting stuck. At the very least a proper error message would be nice.

```

T:\ngfirebaseutil>firebase deploy --debug

Command: C:\Program Files\nodejs\node.exe C:\Users\myusernameAppData\Roaming\npm\node_modulesfirebase-tools\binfirebase deploy --debug
CLI Version: 3.2.1
Platform: win32
Node Version: v7.3.0

Time: Wed Jan 25 2017 11:04:37 GMT-0500 (Eastern Standard Time)

command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"]

HTTP REQUEST GET https://admin.firebase.com/v1/projects/myprojectname-b5558
<<< HTTP RESPONSE 200 via=IG Proxy, date=Wed, 25 Jan 2017 16:04:38 GMT, server=nginx, connection=Close, content-type=application/json; charset=utf-8, cache-control=no-cache, no-store, content-length=103, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains
HTTP REQUEST GET https://admin.firebase.com/v1/database/myprojectname-b5558/tokens
<<< HTTP RESPONSE 200 via=IG Proxy, date=Wed, 25 Jan 2017 16:04:38 GMT, server=nginx, connection=Close, content-type=application/json; charset=utf-8, cache-control=no-cache, no-store, content-length=423, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains```
<>

when I "firebase login" ,there is the problem..I solved by "firebase login --no-localhost" for now. But "firebase init"and "firebase deploy" I can't fix it. Always "Authentication Error"

same problem..

One year and still no fix?

Come on, evil googol..

Same issue here. Here is the command I'm calling and get same error:

firebase database:set /object_name

Same issue here!!!!

"Error: Authentication Error: Your credentials are no longer valid. Please run firebase login --reauth
For CI servers and headless environments, generate a new token with firebase login:ci"

is there no way to deploy behind proxy?

it is my log

[debug] ----------------------------------------------------------------------
[debug] Command:      C:\Program Files\nodejs\node.exe C:\Users\SDS\AppData\Roaming\npm\node_modules\firebase-tools\bin\firebase deploy
[debug] CLI Version:  3.6.1
[debug] Platform:     win32
[debug] Node Version: v7.8.0
[debug] Time:         Mon Apr 17 2017 13:35:27 GMT+0900 (대한민국 표준시)
[debug] ----------------------------------------------------------------------
[debug] 
[debug] > 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"]
[debug] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[debug] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token { refresh_token: '1/cLqub4wdfbPJfm6Rswlzb8L2uA7zXG1SrmTLx17kZ1w',
  client_id: '563584335869-fgrhgmd47bqne........................apps.googleusercontent.com',
  client_secret: 'j9iVZfS8kkCEFU.........',
  grant_type: 'refresh_token',
  scope: 'email https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/firebase openid' } 
 Mon Apr 17 2017 13:35:27 GMT+0900 (대한민국 표준시)
[debug] <<< HTTP RESPONSE 200
[debug] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/sample-b36e9  
 Mon Apr 17 2017 13:35:29 GMT+0900 (대한민국 표준시)
[debug] <<< HTTP RESPONSE 200
[debug] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/sample-b36e9/tokens  
 Mon Apr 17 2017 13:35:30 GMT+0900 (대한민국 표준시)
[debug] <<< HTTP RESPONSE 200

@tingxins hi, did you tried after below command?

set "NODE_TLS_REJECT_UNAUTHORIZED=0"

Firebase devs please solve this issue, it a serious dev delay up to date.

Why is it not solved until now?

one year

It still happens and keeps bothering me... Maybe I will give up firebase because I am in China...

Same problem...

Same problem

Same problem...

Same problem.
Working with support for 3 months and no help.
Finally got the idea to uninstall CovenantEyes, which must have a proxy,
so login did not work.
I guess there must be a number of apps that cause this issue.

Finally got the Woohoo!

capture120

I figured out one possible solution that works for those Shadowsocks proxy users(Windows 10 Pro).

1, run "firebase logout" under Shadowsocks PAC Mode;

2, run "firebase login" under Shadowsocks PAC Mode;

3, switch to Shadowsocks Global Mode(which redirects all your request to the remote serve);

4, try “firebase list” to see if the Authentication Error appears or not.

This works for me, but I am not sure whether it helps or not for you. Worth a try.

#

SOLUTION

#
  1. run 'firebase login --interactive' so log in @gmail account.

This Works!!!

@WbTOne Tried that already. It did not work in my case.

it still doesn't work

Hasta cuando la solución señores de Firebase

Hey,upstairs brother,can you speak English ?

waiting for official solution... this issue has CRITICAL PRIORITY

I can only count on Good luck when debugging, tired of retrying login again and again, it has seriously delayed my project, I have to build my own server now.

For me, it works again when I quit Chrome entirely and reopen it again

I seriously can't believe this isn't fixed in almost a year and a half.

It is always like this if you are an android developer who is living in China.

I just hope that Google Play will come back one day.

wanted to say that i have the problem too
and this is firebase-debug

[debug] [2017-10-09T17:46:10.778Z] ----------------------------------------------------------------------
[debug] [2017-10-09T17:46:10.780Z] Command: C:\Program Files\nodejs\node.exe C:\Users\HamidrezaAppData\Roaming\npm\node_modulesfirebase-tools\binfirebase list
[debug] [2017-10-09T17:46:10.781Z] CLI Version: 3.13.1
[debug] [2017-10-09T17:46:10.781Z] Platform: win32
[debug] [2017-10-09T17:46:10.781Z] Node Version: v6.11.4
[debug] [2017-10-09T17:46:10.781Z] Time: Mon Oct 09 2017 21:16:10 GMT+0330 (Iran Standard Time)
[debug] [2017-10-09T17:46:10.781Z] ----------------------------------------------------------------------
[debug]
[debug] [2017-10-09T17:46:10.794Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"]
[debug] [2017-10-09T17:46:10.795Z] > authorizing via signed-in user
[debug] [2017-10-09T17:46:10.797Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[debug] [2017-10-09T17:46:10.797Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token { refresh_token: '1/OU1dLTZhJUpNdtDzicGy1xtthchW9wu84awgkUkEmGU',
client_id: '563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com',
client_secret: 'j9iVZfS8kkCEFUPaAeJV0sAi',
grant_type: 'refresh_token',
scope: 'email https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/firebase openid' }
Mon Oct 09 2017 21:16:10 GMT+0330 (Iran Standard Time)
[debug] [2017-10-09T17:46:11.815Z] <<< HTTP RESPONSE 200
[debug] [2017-10-09T17:46:11.829Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects
Mon Oct 09 2017 21:16:11 GMT+0330 (Iran Standard Time)
[debug] [2017-10-09T17:46:33.060Z] Error: connect ETIMEDOUT 104.197.85.31:443
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
[error]
[error] Error: Server Error. connect ETIMEDOUT 104.197.85.31:443
[debug] [2017-10-09T17:46:47.934Z] ----------------------------------------------------------------------
[debug] [2017-10-09T17:46:47.937Z] Command: C:\Program Files\nodejs\node.exe C:\Users\HamidrezaAppData\Roaming\npm\node_modulesfirebase-tools\binfirebase list
[debug] [2017-10-09T17:46:47.937Z] CLI Version: 3.13.1
[debug] [2017-10-09T17:46:47.937Z] Platform: win32
[debug] [2017-10-09T17:46:47.937Z] Node Version: v6.11.4
[debug] [2017-10-09T17:46:47.938Z] Time: Mon Oct 09 2017 21:16:47 GMT+0330 (Iran Standard Time)
[debug] [2017-10-09T17:46:47.938Z] ----------------------------------------------------------------------
[debug]
[debug] [2017-10-09T17:46:47.951Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"]
[debug] [2017-10-09T17:46:47.951Z] > authorizing via signed-in user
[debug] [2017-10-09T17:46:47.955Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects
Mon Oct 09 2017 21:16:47 GMT+0330 (Iran Standard Time)
[debug] [2017-10-09T17:47:09.030Z] Error: connect ETIMEDOUT 104.197.85.31:443
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
[error]
[error] Error: Server Error. connect ETIMEDOUT 104.197.85.31:443

I have a same issue, please resolve it!

Same problem, solve it please, can't connect to firebase when using proxy :(

Same issue here.
I am forced to deploy at home... :D

I have a same issue, please resolve it!

Use the proxy on the router.(Shadowsocks)
My computer is connected to this router.

image

Android Studio login Google account is also available.

image

This P2 bug lives for one and half years.

i have same problem here :(

just encountered the same problem here

This worked for me!

set "NODE_TLS_REJECT_UNAUTHORIZED=0"

Cannot deploy too

[debug] [2017-10-31T15:00:41.884Z] ----------------------------------------------------------------------
[debug] [2017-10-31T15:00:41.884Z] Command:       C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\firebase-tools\bin\firebase deploy
[debug] [2017-10-31T15:00:41.884Z] CLI Version:   3.14.0
[debug] [2017-10-31T15:00:41.884Z] Platform:      win32
[debug] [2017-10-31T15:00:41.884Z] Node Version:  v6.11.4
[debug] [2017-10-31T15:00:41.884Z] Time:          Tue Oct 31 2017 13:00:41 GMT-0200 (Horário brasileiro de verão)
[debug] [2017-10-31T15:00:41.884Z] ----------------------------------------------------------------------
[debug] 
[debug] [2017-10-31T15:00:41.904Z] > 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"]
[debug] [2017-10-31T15:00:41.904Z] > authorizing via signed-in user
[debug] [2017-10-31T15:00:41.904Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[debug] [2017-10-31T15:00:41.904Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token { refresh_token: '1/*************************************************************************************',
  client_id: '*************************************************************.com',
  client_secret: '*******************************',
  grant_type: 'refresh_token',
  scope: 'email https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/firebase openid' } 
 Tue Oct 31 2017 13:00:41 GMT-0200 (Horário brasileiro de verão)
[debug] [2017-10-31T15:00:42.285Z] <<< HTTP RESPONSE 200
[debug] [2017-10-31T15:00:42.315Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/where2party-51f6a  
 Tue Oct 31 2017 13:00:42 GMT-0200 (Horário brasileiro de verão)
[debug] [2017-10-31T15:00:43.194Z] <<< HTTP RESPONSE 200
[debug] [2017-10-31T15:00:43.194Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/where2party-51f6a/tokens  
 Tue Oct 31 2017 13:00:43 GMT-0200 (Horário brasileiro de verão)
[debug] [2017-10-31T15:00:44.238Z] <<< HTTP RESPONSE 200

Confirming that this works

confirmed working solution:

  1. set env var http_proxy since is still needed (and being respected) by request
  2. hack faye-websocket/lib/faye/websocket/client.js:
...
var Client = function(_url, protocols, options) {
  options = options || {};

  options.proxy = {
    origin:  'http://localhost:1087',
  }
...
  1. set NODE_TLS_REJECT_UNAUTHORIZED=0
  2. dont trust issue labels such as p2

@namiwang doesn't work for me :(

The main difference is that I use user/password :

var Client = function(_url, protocols, options) {
  options = options || {};

  options.proxy = {
    origin:  'http://user:[email protected]:port',
  }

And when you say set NODE_TLS_REJECT_UNAUTHORIZED=0, the command on linux is export NODE_TLS_REJECT_UNAUTHORIZED=0, right ?

Seems like this should be such a simple thing to fix. Slowing me down big time....

  1. Firebase login doesn't work on corporate laptop, Windows only.
    Firebase: 3.16.0
    Npm: 5.3.0
    Windows: 7, x64
    Proxy: http://proxy.XXXXXXX.com:80

  2. Tried to install and login from my home laptop and it worked.
    Windows: 10, x64

  3. We do have corporate proxy, but in some reason it becomes problem only on laptops with Windows, tried corporate laptops with MacOS and "firebase login" works fine on them.

  4. After disabling some error handlers in the file below browser says that URL http://localhost:9005 is not available, so most probably it's not just a proxy, but rather some port is closed by Windows Firewall.
    C:\Users\AppData\Roaming\npm\node_modulesfirebase-tools\lib\api.js

  5. Debug information
    https://i.imgur.com/lslydoN.png

Update. Just made login working.

1) run Git Bash or any Linux-like command line tool
2) execute these commands, substitute your proxy instead

export HTTP_PROXY="http://proxy.XXXXXXXX.com:80/"
export HTTPS_PROXY="http://proxy.XXXXXXXX.com:80/"

3) after this I was able to login using

firebase login --interactive

4) useful links

https://github.com/firebase/firebase-tools/issues/36#issuecomment-66696746
https://www.npmjs.com/package/request#controlling-proxy-behaviour-using-environment-variables

As about "firebase deploy" - still have this issue. No errors, it just hangs.

I am not running behind a proxy but i am seeing this issue. I am getting the following error while deploying the code.
** Error: Server Error. connect ETIMEDOUT 172.217.31.202:443

So i did "firebase login --reauth" and provided correct credentials, but when i executed "firebase list" I got the following error even though I was logged in successfully.
**Error: Authentication Error: Your credentials are no longer valid. Please run firebase login --reauth

Then i followed the following steps to resolve the issue.
firebase logout
firebase login -> Successful login
firebase list -> I can see my apps
firebase deploy -> I can deploy the code successfully.

Came up for me when working on hotel internet...

Sitting in front of my laptop, facing the same error go on and on again.

Same for me, pretty sad deploy is not working behind a proxy :-(.
Firebase tools are still awesome though

I work around it via SSH.

I have a VPS so I cloned my project in it and login Firebase.
Once I need to deploy new functions, just invoke a remote script via SSH.

Here is some scripts:

  • deployFunctionsRemote.sh in local

    #!/usr/bin/env bash
    
    # funDir point to your functions directory
    funDir=${PROJECT}/functions
    
    # Using rsync cmd to upload local changes to the remote project
    # Excluding node_modules directory is recommend
    cmdLine="rsync -avzPr --rsh='ssh -p ${REMOTE_PORT}' --exclude=node_modules ${funDir} ${REMOTE_USR}@${REMOTE_IP}:${REMOTE_PROJECT}"
    eval ${cmdLine}
    
    # Invoke remote deploy script
    remoteDeployScript=${REMOTE_PROJECT}/deployFunctions.sh
    ssh -p ${REMOTE_PORT} ${REMOTE_USR}@${REMOTE_IP} "${remoteDeployScript}"
    
  • deployFunctions.sh in remote

    #!/usr/bin/env bash
    firebase deploy --only functions
    

Same problem :(

same here
i solved this by sharing my mobile network...

lol, two years login not worked

we need a proxy option in firebase tools when firebase login

https://github.com/firebase/firebase-tools/issues/155#issuecomment-349345985

works for me.
open console, enter a export variables with proxy options of my company
and enter firebase login --no-localhost
and open browser, login via google, copy token and put it to console
and work!)

Everything except deploying to hosting ought to work behind a proxy by
setting environment variables. Anything that doesn't, please provide a
detailed report.

On Sun, Jan 28, 2018, 12:54 PM Sergey S. Volkov notifications@github.com
wrote:

155 (comment)

https://github.com/firebase/firebase-tools/issues/155#issuecomment-349345985

works for me.
open console, enter a export variables with proxy options of my company
and enter firebase login --no-localhost
and open browser, login via google, copy token and put it to console
and work!)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebase-tools/issues/155#issuecomment-361095081,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAD_kJ7g2hTyHtLlfnTUK3VCUxY046Iks5tPN6OgaJpZM4InPdh
.

When I set HTTP_PROXY and providing authentication in proxy url, I am returned a Server Error. tunneling socket could not be established, statusCode=407 error

Ok i manage to do something like @namiwang explained before.

Here are some informations about versions i use.
node: 7.5.0
npm: 4.1.2
firebase: 3.13.1

firebase-tools is installed globally, so I have to modify the proxy settings where firebase-tools is installed.
In my case it is at ~/.nvm/versions/node/v7.5.0/lib/node_modules/firebase-tools

1) Open file ~/.nvm/versions/node/v7.5.0/lib/node_modules/firebase-tools/node_modules/firebase/node_modules/faye-websocket/lib/faye/websocket/client.js

2) Modify lines

  options = options || {};
  this.url     = _url;

to

  options = options || {};
  options.proxy = {
    origin: 'http://user:[email protected]:3128',
    headers: {'User-Agent': 'node'},
  };
  this.url     = _url;

3) Go on your project then launch firebase command to deploy

cd ~/workspace/myProject/functions
firebase deploy --only functions

Cool. Could we do something like this though?

if (process.env.HTTP_SERVER) {
   options.proxy = {
      origin: process.env.HTTP_SERVER,
      headers: { 'User-Agent': 'node' }
   };
}

Thank you @namiwang for your help. it worked for me...

The "deploy hang" is still a problem and can not be fixed setting proxy env var... any soluton to this?

It is unacceptable, after two years, this problem is still not fixed? wth?

@LastStranger try this https://github.com/firebase/firebase-tools/issues/155#issuecomment-349345985

But I use firebase login --no-localhost no-localhost flag

@js2me export HTTPS_PROXY="http://proxy.XXXXXXXX.com:80/" ??? I tried to run this in my powershell and cmd, but it seems it couldn't reslove the"export"

@LastStranger Hmm, its odd. Do you try this in git bash?

how to set NODE_TLS_REJECT_UNAUTHORIZED=0 on windows

share my solution for who work inside and wanna live outside the GFW.

Env: MacOS with shadowsocks-ng

~/.bash_profile

alias cbrew="ALL_PROXY=socks5://127.0.0.1:1086 brew"

# using polipo
alias cfirebase="http_proxy=http://127.0.0.1:8123 firebase"

# your shadowsocks may already have http proxy feature
alias cfirebase="http_proxy=http://127.0.0.1:1087 firebase"

up polipo http proxy (optional)

cbrew install polipo
polipo socksParentProxy=localhost:1086 &

login

cfirebase login --debug

polyfill faye-websocket

Thanks @namiwang it works.

because firebase sdk 2.x.x is minified, so... polyfill faye-websocket is easier than fix sdk.

// if you installed node by brew, the path would be /usr/local/lib/node_modules/firebase-tools/node_modules/firebase/node_modules/faye-websocket/lib/faye/websocket/client.js
...
var proxy_uri = process.env.http_proxy
if (proxy_uri) {
  options.proxy = { origin: proxy_uri }
}
...

deploy

cfirebase deploy --only functions --debug

Actually, newer firebase sdk already fixed the bug. Waiting firebase-tools up deps to date...

It's 2018, still no fix to it, look likes they don't maintain it.

Not work

很难受 还没解决- -?

@victorsferreira

i solved this by sharing my mobile network...

This also solved my "deploy functions" problem.

Google being, Google. Another critical bug that will not be solved.

As chinese ,if we need access google,we must use proxy!!!Because of the GWF

One solution could be, to move to another country 💃

This is useful also for CI deployments

so, I have to give up using firebase? In China , without proxy I can not even search in google. As if i have seen a crystal cake , I can not eat .

I hope to have some good news on this front when some infrastructure work
we're doing now comes through. I don't have a specific timeline to provide,
however.

Sorry for the long delay in addressing this issue, it has been much more
complicated than you'd think.

On Fri, Jun 29, 2018, 1:12 AM noobhui notifications@github.com wrote:

so, I have to give up using firebase? In China , without proxy I can not
even search in google. As if i have seen a crystal cake , I can not eat .


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebase-tools/issues/155#issuecomment-401282471,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAD_hDs8s1zUkv3-8QFYSxcvCFrNFs2ks5uBeFagaJpZM4InPdh
.

So far as i know, only needed is a patched firebase sdk v2, can pass the env.http_proxy to the module faye-websocket, or up sdk to date (v4)

Would u mind tell us why it much more complicated than we think?
Maybe we can help.

Thanks.

For those having the issue in Windows : this comment works on Linux (export is a Linux command), but you can manage to make it work on Windows.

Start by installing Cmder, which a simple console emulator. Next, you will have to run a bash shell (not a powershell, not a cmd shell, a bash shell).

Once the bash shell is made, you can indeed run those two commands :

export HTTP_PROXY="your proxy"
export HTTPS_PROXY="your proxy"

Which will set your Windows proxy (I don't know how, I didn't seem to find what it did in env variables or internet options). From this, firebase can simply be ran with firebase login without any more issue.

I have tried all of the solutions in this issue ( except modifying the library, I'm not a savage :D ), and this is the only one that worked for me. I hope this helps !

facing same issue... when will google solve this?

I have same issue, I logged in to Firebase -CLI by firebase login and then I try to run firebase use --add in my command line for choosing my proper project and fell in this error:

Error: Server Error. connect ETIMEDOUT 104.197.85.31:443

getting mad by this error. When we can get some fix. I can't complete my project with firebase :(

Does not work for me either. Tried a bunch of solution, can't believe firebase can't handle proxies.

After a year still getting the same error., whom to blame China Firewall or Google Firebase..,

`? Allow Firebase to collect anonymous CLI usage and error reporting information? (Y/n)

PS C:\Users\murugan_nagarajan> firebase login --debug
[2018-08-10T07:22:00.621Z] ----------------------------------------------------------------------
[2018-08-10T07:22:00.626Z] Command: C:\Program Files\nodejs\node.exe C:\Users\murugan_nagarajanAppData\Roaming\npm\node_modulesfirebase-tools\binfirebase login --debug
[2018-08-10T07:22:00.627Z] CLI Version: 4.0.3
[2018-08-10T07:22:00.627Z] Platform: win32
[2018-08-10T07:22:00.627Z] Node Version: v10.8.0
[2018-08-10T07:22:00.629Z] Time: Fri Aug 10 2018 15:22:00 GMT+0800 (China Standard Time)
[2018-08-10T07:22:00.630Z] ----------------------------------------------------------------------

? Allow Firebase to collect anonymous CLI usage and error reporting information? No

Visit this URL on any device to log in:
https://accounts.google.com/o/oauth2/auth?client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&scope=email%20openid%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcl
oudplatformprojects.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ffirebase%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&response_type=code&state=452226808&redirect_uri=htt
p%3A%2F%2Flocalhost%3A9005

Waiting for authentication...
[2018-08-10T07:22:48.312Z] >>> HTTP REQUEST POST https://accounts.google.com/o/oauth2/token
{ code:
'4/NwD80jRUIDzAwBxmuqqIQxaOPyLfiOUL1Yx5eKGKzqtnfk88q4anmyxTozeLKQEE9DOxPuMklrrc42teX491Kuw',
client_id:
'563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com',
client_secret: 'j9iVZfS8kkCEFUPaAeJV0sAi',
redirect_uri: 'http://localhost:9005',
grant_type: 'authorization_code' }
Fri Aug 10 2018 15:22:48 GMT+0800 (China Standard Time)
[2018-08-10T07:22:48.455Z] Token Fetch Error: Error
at new FirebaseError (C:\Users\murugan_nagarajanAppData\Roaming\npm\node_modulesfirebase-tools\lib\error.js:11:16)
at Request._callback (C:\Users\murugan_nagarajanAppData\Roaming\npm\node_modulesfirebase-tools\lib\api.js:35:11)
at self.callback (C:\Users\murugan_nagarajanAppData\Roaming\npm\node_modulesfirebase-tools\node_modulesrequestrequest.js:185:22)
at Request.emit (events.js:182:13)
at Request.EventEmitter.emit (domain.js:442:20)
at Request.onRequestError (C:\Users\murugan_nagarajanAppData\Roaming\npm\node_modulesfirebase-tools\node_modulesrequestrequest.js:877:8)
at ClientRequest.emit (events.js:182:13)
at ClientRequest.EventEmitter.emit (domain.js:442:20)
at TLSSocket.socketErrorListener (_http_client.js:382:9)
at TLSSocket.emit (events.js:182:13)
^CTerminate batch job (Y/N)?`

All right folks, it's time to fix this bug once and for all! With the release of v4.1.0, the Firebase CLI no longer depends on a websocket connection for Hosting deploys. That means that everything is done through standard HTTP requests, which should be able to be easily made to work with proxies.

I am going to try to get a test proxy running locally to work on this myself, but for those affected:

  1. Does v4.1.0 "just work" or are you still having errors?
  2. Does setting the HTTPS_PROXY environment variable work for you?

I know it's been a long road, but (I hope) it will be coming to an end very soon. Please report back with your experience with 4.1.0, and we'll start working through any remaining problems!

@mbleigh I can confirm it works fine with HTTPS_PROXY set in 4.1.0. 👍

Update: yesterday I found myself stuck too. You can see it stuck here with --debug enabled:

[2018-08-17T15:50:53.061Z] <<< HTTP RESPONSE 200 server=nginx, date=Fri, 17 Aug 2018 15:50:52 GMT, content-type=application/json; charset=utf-8, content-length=255, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store

After upgrade to 4.1.2, everything looks fine for me now.

upgraded to v4.1.0, also set HTTPS_PROXY.
firebase login, logout, list works well, but deploy still stuck after getting token.

after upgrading to v4.1.0 and setting HTTP_PROXY login works... but stuck on firebase deploy

Folks who are putting in reports, can you please include the last few lines of your debug logs (omitting any auth tokens) running with --debug as well as the type of proxy you're running behind (if you know it).

We have made some additional updates in v4.1.2 that might fix firebase deploy proxy issues. Please give it a try and let me know if it's not working!

@mbleigh what proxy types does firebase command support? For example, gcloud command supports http, http_no_tunnel, socks4, socks5 proxy types. In my test, the newest version of firebase still can't support socks5.

Does firebase use request as it's http client library? It supports http/https proxy type, but I don't know if it supports other types like socks5.

In the firebase v4.2.0, you can add a proxy server to connent server.

edit the request.js which locate in $NODE_PATH/node_modules/request/request.js:290

// line 290 to 298
 // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }
  self.proxy = 'http://127.0.0.1:1087'    // add proxy server
  self.tunnel = self._tunnel.isEnabled()

  if (self.proxy) {
    self._tunnel.setup(options)
  }

Therefore, Login is success! 😃


Don't forget delete proxy server setting after login success.

@chen86860 No, you don't modify the source code now, just export proxy in your environment:

$ export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;

@hanguokai currently we have support for http_proxy and https_proxy environment variables (but nothing else). I think support for socks4 socks5 should probably go in a different feature request -- feel free to file one!

Alright, I add another issue #883 for socks proxy support.

I know some applications also support environment variables for socks proxy, like:
export http_proxy=socks5://127.0.0.1:1080 https_proxy=socks5://127.0.0.1:1080

Hope firebase command support it too.

Hi,
I confirm that in my environment this bug is fixed with v4.1.2

OK folks, here's where we're at:

I think that we now have support for HTTP and HTTPS proxies via setting the correct environment variables. I'm going to close this issue based on the feedback I've received that our recent releases have addressed the issue.

If you are using a socks proxy, please go leave an upvote for #883. If you are still experiencing issues with an HTTP/S proxy and you've properly set the HTTP_PROXY and HTTPS_PROXY environment variables, please comment in this thread with as much detail as you can provide.

@chenxsan Oh, it look like a better way to fix this, Thanks~ 😆

firebase login --no-localhost

This command fixed it for me behind proxy

In the firebase v4.2.0, you can add a proxy server to connent server.

edit the request.js which locate in $NODE_PATH/node_modules/request/request.js:290

// line 290 to 298
 // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }
  self.proxy = 'http://127.0.0.1:1087'    // add proxy server
  self.tunnel = self._tunnel.isEnabled()

  if (self.proxy) {
    self._tunnel.setup(options)
  }

Therefore, Login is success! 😃

Don't forget delete proxy server setting after login success.

Great!!!

@chen86860 No, you don't modify the source code now, just export proxy in your environment:

$ export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;

i just run the script in terminal,but still get same error.What's wrong there?
yongjiamingdeMacBook-Pro:firebase yongjiaming$ firebase login --debug
[2018-09-18T03:33:08.860Z] ----------------------------------------------------------------------
[2018-09-18T03:33:08.863Z] Command: /usr/local/Cellar/node/9.6.1/bin/node /usr/local/bin/firebase login --debug
[2018-09-18T03:33:08.864Z] CLI Version: 4.2.1
[2018-09-18T03:33:08.864Z] Platform: darwin
[2018-09-18T03:33:08.864Z] Node Version: v9.6.1
[2018-09-18T03:33:08.864Z] Time: Tue Sep 18 2018 11:33:08 GMT+0800 (CST)
[2018-09-18T03:33:08.864Z] ----------------------------------------------------------------------

? Allow Firebase to collect anonymous CLI usage and error reporting information? Yes

Visit this URL on any device to log in:
https://accounts.google.com/o/oauth2/auth?client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&scope=email%20openid%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloudplatformprojects.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ffirebase%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&response_type=code&state=971322293&redirect_uri=http%3A%2F%2Flocalhost%3A9005

Waiting for authentication...
[2018-09-18T03:33:16.437Z] >>> HTTP REQUEST POST https://accounts.google.com/o/oauth2/token
code=4/XgBxvL5SXC-Wg5vT8CCTdfLIoTPKVkCOFcmVku25RwRlkLUc-inqxg6mPRNX7JKRA8fWufJEm-7e5BKTbfFCmsk, client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com, client_secret=j9iVZfS8kkCEFUPaAeJV0sAi, redirect_uri=http://localhost:9005, grant_type=authorization_code
[2018-09-18T03:33:16.454Z] Token Fetch Error: Error
at new FirebaseError (/usr/local/lib/node_modules/firebase-tools/lib/error.js:11:16)
at Request._callback (/usr/local/lib/node_modules/firebase-tools/lib/api.js:34:11)
at self.callback (/usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js:185:22)
at Request.emit (events.js:127:13)
at Request.emit (domain.js:421:20)
at Request.onRequestError (/usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js:881:8)
at ClientRequest.emit (events.js:127:13)
at ClientRequest.emit (domain.js:421:20)
at ClientRequest.onError (/usr/local/lib/node_modules/firebase-tools/node_modules/tunnel-agent/index.js:179:21)
at Object.onceWrapper (events.js:219:13)
^Z
[1]+ Stopped firebase login --debug

I have a problem with deploying my project to firebase behind a proxy as well.
Sign in works without a problem.

http_proxy and https_proxy are set to the cntlm.
The commands I tried are:

firebase deploy -P <projectname> --token <token> --debug
firebase deploy -P <projectname> --debug

This is the output:

firebase deploy -P prod --debug
[2018-09-20T09:42:15.911Z] ----------------------------------------------------------------------
[2018-09-20T09:42:15.926Z] Command:       C:\Program Files\nodejs\node.exe C:\Users\<user>\AppData\Roaming\npm\node_modules\firebase-tools\bin\firebase deploy -P prod --debug
[2018-09-20T09:42:15.942Z] CLI Version:   4.2.1
[2018-09-20T09:42:15.942Z] Platform:      win32
[2018-09-20T09:42:15.942Z] Node Version:  v8.11.3
[2018-09-20T09:42:15.942Z] Time:          Thu Sep 20 2018 11:42:15 GMT+0200 (Mitteleuropäische Sommerzeit)
[2018-09-20T09:42:15.942Z] ----------------------------------------------------------------------

[2018-09-20T09:42:15.973Z] > 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"]
[2018-09-20T09:42:15.975Z] > authorizing via signed-in user
[2018-09-20T09:42:15.978Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[2018-09-20T09:42:15.979Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token
 refresh_token=<token>, client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com, client_secret=j9iVZfS8kkCEFUPaAeJV0sAi, grant_type=refresh_token, scope=email https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/firebase openid
[2018-09-20T09:42:16.321Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=utf-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Thu, 20 Sep 2018 09:42:16 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="44,43,39,35", accept-ranges=none, connection=close
[2018-09-20T09:42:16.332Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/<project>


!  Your CLI authentication needs to be updated to take advantage of new features.
!  Please run firebase login --reauth

[2018-09-20T09:42:16.485Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"]
[2018-09-20T09:42:16.485Z] > authorizing via signed-in user
[2018-09-20T09:42:16.485Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[2018-09-20T09:42:16.485Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token
 refresh_token=<token>, client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com, client_secret=j9iVZfS8kkCEFUPaAeJV0sAi, grant_type=refresh_token, scope=email https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/firebase openid
[2018-09-20T09:42:16.740Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=utf-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Thu, 20 Sep 2018 09:42:16 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="44,43,39,35", accept-ranges=none, connection=close
[2018-09-20T09:42:16.769Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/<project>

[2018-09-20T09:42:16.861Z] Error: tunneling socket could not be established, statusCode=407
    at ClientRequest.onConnect (C:\Users\<user>\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\tunnel-agent\index.js:166:19)
    at Object.onceWrapper (events.js:319:30)
    at emitThree (events.js:136:13)
    at ClientRequest.emit (events.js:217:7)
    at Socket.socketOnData (_http_client.js:474:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)

Error: Server Error. tunneling socket could not be established, statusCode=407

@chen86860 No, you don't modify the source code now, just export proxy in your environment:

$ export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;

i just run the script in terminal,but still get same error.What's wrong there?
yongjiamingdeMacBook-Pro:firebase yongjiaming$ firebase login --debug
[2018-09-18T03:33:08.860Z] ----------------------------------------------------------------------
[2018-09-18T03:33:08.863Z] Command: /usr/local/Cellar/node/9.6.1/bin/node /usr/local/bin/firebase login --debug
[2018-09-18T03:33:08.864Z] CLI Version: 4.2.1
[2018-09-18T03:33:08.864Z] Platform: darwin
[2018-09-18T03:33:08.864Z] Node Version: v9.6.1
[2018-09-18T03:33:08.864Z] Time: Tue Sep 18 2018 11:33:08 GMT+0800 (CST)
[2018-09-18T03:33:08.864Z] ----------------------------------------------------------------------

? Allow Firebase to collect anonymous CLI usage and error reporting information? Yes

Visit this URL on any device to log in:
https://accounts.google.com/o/oauth2/auth?client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&scope=email%20openid%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloudplatformprojects.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ffirebase%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&response_type=code&state=971322293&redirect_uri=http%3A%2F%2Flocalhost%3A9005

Waiting for authentication...
[2018-09-18T03:33:16.437Z] >>> HTTP REQUEST POST https://accounts.google.com/o/oauth2/token
code=4/XgBxvL5SXC-Wg5vT8CCTdfLIoTPKVkCOFcmVku25RwRlkLUc-inqxg6mPRNX7JKRA8fWufJEm-7e5BKTbfFCmsk, client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com, client_secret=j9iVZfS8kkCEFUPaAeJV0sAi, redirect_uri=http://localhost:9005, grant_type=authorization_code
[2018-09-18T03:33:16.454Z] Token Fetch Error: Error
at new FirebaseError (/usr/local/lib/node_modules/firebase-tools/lib/error.js:11:16)
at Request._callback (/usr/local/lib/node_modules/firebase-tools/lib/api.js:34:11)
at self.callback (/usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js:185:22)
at Request.emit (events.js:127:13)
at Request.emit (domain.js:421:20)
at Request.onRequestError (/usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js:881:8)
at ClientRequest.emit (events.js:127:13)
at ClientRequest.emit (domain.js:421:20)
at ClientRequest.onError (/usr/local/lib/node_modules/firebase-tools/node_modules/tunnel-agent/index.js:179:21)
at Object.onceWrapper (events.js:219:13)
^Z
[1]+ Stopped firebase login --debug

just update to the latest shadowscoks ,everything go all right~

I'm living in China, so it's really difficult to use Google's products thanks to GFW. Currently I'm using Shadowsocks listening at 1080 port for accessing Google service.

Here is another problem, if you want to run firebase serve to serve dynamic functions, you cannot use http_proxy=socks5://127.0.0.1:1080, because the localhost request will also be proxied in this way.

I solved this by use only https_proxy=socks5://127.0.0.1:1080,

Summary

Login

firebase login --no-localhost

Serve

export https_proxy=socks5://127.0.0.1:1080
firebase serve

Deploy

Add the follwowing code between BEGIN_PROXY and AFTER_PROXY to your functions/node_modules/faye-websocket/lib/faye/websocket/client.js

// ...
var Client = function(_url, protocols, options) {
  options = options || {};

  // BEGIN_PROXY
  options.proxy = {
    origin:  'http://localhost:8888',
    headers: {'User-Agent': 'node'},
  }
  // AFTER_PROXY

// ...
firebase deploy


Click to see my log

upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ firebase login --no-localhost
? Allow Firebase to collect anonymous CLI usage and error reporting
 information? No

Visit this URL on any device to log in:
https://accounts.google.com/o/oauth2/auth?client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&scope=email%20openid%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloudplatformprojects.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ffirebase%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&response_type=code&state=928286882&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob

? Paste authorization code here: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

+  Success! Logged in as [email protected]

upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ firebase serve

=== Serving from 'E:\github\firebase-test'...

i  functions: Preparing to emulate functions.
i  hosting: Serving hosting files from: public
+  hosting: Local server: http://localhost:5000
Warning: You're using Node.js v8.11.3 but Google Cloud Functions only supports v6.11.5.
+  functions: app: http://localhost:5001/learning-13a18/us-central1/app
127.0.0.1 - - [08/Nov/2018:04:40:35 +0000] "GET / HTTP/1.1" 200 3505 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [08/Nov/2018:04:40:37 +0000] "GET /__/firebase/init.js HTTP/1.1" 200 - "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [08/Nov/2018:04:40:37 +0000] "GET /__/firebase/5.5.7/firebase-app.js HTTP/1.1" 200 - "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [08/Nov/2018:04:40:38 +0000] "GET /__/firebase/5.5.7/firebase-auth.js HTTP/1.1" 200 - "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [08/Nov/2018:04:40:38 +0000] "GET /__/firebase/5.5.7/firebase-messaging.js HTTP/1.1" 200 - "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [08/Nov/2018:04:40:38 +0000] "GET /__/firebase/5.5.7/firebase-database.js HTTP/1.1" 200 - "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [08/Nov/2018:04:40:39 +0000] "GET /__/firebase/5.5.7/firebase-storage.js HTTP/1.1" 200 - "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
127.0.0.1 - - [08/Nov/2018:04:40:40 +0000] "GET /favicon.ico HTTP/1.1" 404 1808 "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0;
Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
[hosting] Rewriting /timestamp to local function app
info: User function triggered, starting execution
info: Execution took 23 ms, user function completed successfully
127.0.0.1 - - [08/Nov/2018:04:40:41 +0000] "GET /timestamp HTTP/1.1" 200 13 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
[hosting] Rewriting /timestamp to local function app
info: User function triggered, starting execution
info: Execution took 2 ms, user function completed successfully
127.0.0.1 - - [08/Nov/2018:04:40:43 +0000] "GET /timestamp HTTP/1.1" 200 13 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
Shutting down...


upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ export http_proxy=socks5://127.0.0.1:1080

upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ firebase serve

Error: Server Error. socket hang up

upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ export http_proxy=

upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ firebase serve

=== Serving from 'E:\github\firebase-test'...

i  functions: Preparing to emulate functions.
i  hosting: Serving hosting files from: public
+  hosting: Local server: http://localhost:5000
Warning: You're using Node.js v8.11.3 but Google Cloud Functions only supports v6.11.5.
+  functions: app: http://localhost:5001/learning-13a18/us-central1/app
Shutting down...


upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ firebase deploy

Error: Server Error. socket hang up

upupming@DESKTOP-6EB87T6 MINGW64 /e/github/firebase-test
$ firebase deploy

=== Deploying to 'learning-13a18'...

i  deploying functions, hosting
Running command: npm --prefix "%RESOURCE_DIR%" run lint

> functions@ lint E:\github\firebase-test\functions
> eslint .

+  functions: Finished running predeploy script.
i  functions: ensuring necessary APIs are enabled...
+  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (52.46 KB) for uploading
+  functions: functions folder uploaded successfully
i  hosting[learning-13a18]: beginning deploy...
i  hosting[learning-13a18]: found 2 files in public
+  hosting[learning-13a18]: file upload complete
i  functions: updating Node.js 6 function app(us-central1)...
+  functions[app(us-central1)]: Successful update operation.
i  hosting[learning-13a18]: finalizing version...
+  hosting[learning-13a18]: version finalized
i  hosting[learning-13a18]: releasing new version...
+  hosting[learning-13a18]: release complete

+  Deploy complete!

Project Console: https://console.firebase.google.com/project/learning-13a18/overviewHosting URL: https://learning-13a18.firebaseapp.com

Alternative solution

If you are always using home WiFi network, you can config Shadowsocks proxy on your router. See this repo for more information.

I'm living in China, so it's really difficult to use Google's products thanks to GFW. Currently I'm using Shadowsocks listening at 1080 port for accessing Google service.

Here is another problem, if you want to run firebase serve to serve dynamic functions, you cannot use http_proxy=socks5://127.0.0.1:1080, because the localhost request will also be proxied in this way.

I solved this by use only https_proxy=socks5://127.0.0.1:1080,

Summary

Login

firebase login --no-localhost

Serve

export https_proxy=socks5://127.0.0.1:1080
firebase serve

Deploy

Add the follwowing code between BEGIN_PROXY and AFTER_PROXY to your functions/node_modules/faye-websocket/lib/faye/websocket/client.js

// ...
var Client = function(_url, protocols, options) {
  options = options || {};

  // BEGIN_PROXY
  options.proxy = {
    origin:  'http://localhost:8888',
    headers: {'User-Agent': 'node'},
  }
  // AFTER_PROXY

// ...
firebase deploy

Click to see my log

Alternative solution

If you are always using home WiFi network, you can config Shadowsocks proxy on your router. See this repo for more information.

export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;export NO_PROXY=localhost,127.0.0.1

2019 Still doesn't work! any luck?

I am not behind proxy. Login is succecssfull and facing this same issue in deploy.

export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;export NO_PROXY=localhost,127.0.0.1

Worked for me behind shadowsocks in China. Thanks!

same problem ..

Hello guys! Here is another solution which is pretty simple and you don't need to edit any file. Instead of using Shadowsocks/ShadowsocksR, try SSTap. SSTap creates a virtual network card. I don't know how to explain, but it works just like that you run Shadowsocks(R) on your router. Worked for me.

export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;export NO_PROXY=localhost,127.0.0.1

It works on my Mac with shadowsocks in China. Thanks a lot!

in Powershell on Windows 10 powered by shadowsocks.

PS> $env:http_proxy = 'http://127.0.0.1:1080'
PS> $env:https_proxy = 'http://127.0.0.1:1080'
PS> $env:NO_PROXY = 'localhost,127.0.0.1'
PS> firebase login

2019/03/24, still failed on my mac air

Hello guys! Here is another solution which is pretty simple and you don't need to edit any file. Instead of using Shadowsocks/ShadowsocksR, try SSTap. SSTap creates a virtual network card. I don't know how to explain, but it works just like that you run Shadowsocks(R) on your router. Worked for me.

@yqx1110 Thanks very much, this is the most powerful tool I have ever seen.

failed, not work

Hello, I just found the solution. Please follow the link https://qiita.com/tanoc/items/ac92464de473ae483d50

Hello, I just found the solution. Please follow the link https://qiita.com/tanoc/items/ac92464de473ae483d50

The above also works for Clasp. Thank you

in Powershell on Windows 10 powered by shadowsocks.

PS> $env:http_proxy = 'http://127.0.0.1:1080'
PS> $env:https_proxy = 'http://127.0.0.1:1080'
PS> $env:NO_PROXY = 'localhost,127.0.0.1'
PS> firebase login

Thanks, it works for me on win10.

Mad it work on Mac using this trick

Screen Shot 2019-07-19 at 12 45 14

  1. Go the the network proxy setting on Mac and change Proxy Server and port from CNTL local host to actual enterprise server and port.
    Screen Shot 2019-07-19 at 13 06 34

    1. No in the terminal temporary authenticate proxy

ProxyPass & ProxyUserName : same as login credentials stored in CNTLM
ProxyServer & ProxyPort: same as what you have set in network settings.

export http_proxy=http://<ProxyUserName>:<ProxyPass>@<ProxyServer>:<ProxyPort>
export https_proxy=http://<ProxyUserName>:<ProxyPass>@<ProxyServer>:<ProxyPort>

now I was able to login normally on firebase & deploy cloud functions. Hope it works

export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;export NO_PROXY=localhost,127.0.0.1

Works for me! Thx.

2019.8.10 I've tried almost all the solutions above, and it's not working. sadly...

@starry
work for me , thanks

in Powershell on Windows 10 powered by shadowsocks.

PS> set http_proxy = 'http://127.0.0.1:1080'
PS> set https_proxy = 'http://127.0.0.1:1080'
PS>set NO_PROXY = 'localhost,127.0.0.1'
PS> firebase login

In win10,this works for me, 1080 is my proxy port

Mad it work on Mac using this trick

Screen Shot 2019-07-19 at 12 45 14

  1. Go the the network proxy setting on Mac and change Proxy Server and port from CNTL local host to actual enterprise server and port.

Screen Shot 2019-07-19 at 13 06 34

  1. No in the terminal temporary authenticate proxy

ProxyPass & ProxyUserName : same as login credentials stored in CNTLM
ProxyServer & ProxyPort: same as what you have set in network settings.

export http_proxy=http://<ProxyUserName>:<ProxyPass>@<ProxyServer>:<ProxyPort>
export https_proxy=http://<ProxyUserName>:<ProxyPass>@<ProxyServer>:<ProxyPort>

now I was able to login normally on firebase & deploy cloud functions. Hope it works

It works for me! Thanks. 😇

still experiencing this issue, can't believe it is still around in 2020 ...

Same issue.

For people who use v2ray for proxy on mac:

  1. Find the proxy in setting:
    image
  2. Export the proxy in your terminal:
    export http_proxy=http://localhost:1087 (This is my proxy address)
  3. Find the faye lib in the folder of firebase tool in your global nodejs folder. The path example can be like this. You can find this via search "faye" on your mac.
    /node_modules/firebase-tools/node_modules/firebase/node_modules/faye-websocket/lib/faye/websocket/client.js
  4. Add proxy for faye as config. You need to edit the client.js file of faye.
    var Client = function(_url, protocols, options) {
    options = options || {};
    // Add the proxy here for faye which firebase uses
    options.proxy = {
    origin: 'http://localhost:1087',
    };

    }
    5.export NODE_TLS_REJECT_UNAUTHORIZED=0 through the terminal
    6.firebase login --no-localhost through the terminal

Hope this will help:
The main logic here is to tell the faye there is a proxy on my local machine

Hope this will help you:
[email protected]
it works on both win and mac with ssr

  1. find your proxy address
    WeChatd29e8b5b594f8cff963da7441b84fbc9

  2. open "request.js" file in your firebase tools folder. for me, the path is
    /usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js
    use "npm root -g" to find your global npm path

  3. find the code below, about line 276

  if (!self.hasOwnProperty('proxy')) {
    self.proxy = getProxyFromURI(self.uri)
  }

change it to

  // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }
  self.proxy = "http://127.0.0.1:1087";  // this is your proxy address
  1. use firebase login --no-localhost

Hope this will help you:
[email protected]
it works on both win and mac with ssr

  1. find your proxy address

WeChatd29e8b5b594f8cff963da7441b84fbc9

  1. open "request.js" file in your firebase tools folder. for me, the path is
    /usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js
    use "npm root -g" to find your global npm path
  2. find the code below, about line 276
  if (!self.hasOwnProperty('proxy')) {
    self.proxy = getProxyFromURI(self.uri)
  }

change it to

  // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }
  self.proxy = "http://127.0.0.1:1087";  // this is your proxy address
  1. use firebase login --no-localhost

It works for me! You really save my ass! Thanks!

Is there a solution for this issue in latest versions?

Hope this will help you:

steps are the same as before. The new file location: .../firebase-tools/lib/api.js

find the code below, around line 297

reqOptions.headers = options.headers; reqOptions.timeout = options.timeout;

append reqOptions.proxy = "http://127.0.0.1:10818";

run firebase login --no-localhost

Thanks for pointing this out @jplyue was almost getting crazy about the new Firebase Tools Version not working with our corporate Proxy anymore.

Hope this will help you:
[email protected]
it works on both win and mac with ssr

  1. find your proxy address

WeChatd29e8b5b594f8cff963da7441b84fbc9

  1. open "request.js" file in your firebase tools folder. for me, the path is
    /usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js
    use "npm root -g" to find your global npm path
  2. find the code below, about line 276
  if (!self.hasOwnProperty('proxy')) {
    self.proxy = getProxyFromURI(self.uri)
  }

change it to

  // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }
  self.proxy = "http://127.0.0.1:1087";  // this is your proxy address
  1. use firebase login --no-localhost

WORKS FOR ME!!!!!!!!!

it is real pain to use firebase from a proxy :(

Mad it work on Mac using this trick
Screen Shot 2019-07-19 at 12 45 14

  1. Go the the network proxy setting on Mac and change Proxy Server and port from CNTL local host to actual enterprise server and port.

Screen Shot 2019-07-19 at 13 06 34

  1. No in the terminal temporary authenticate proxy

ProxyPass & ProxyUserName : same as login credentials stored in CNTLM
ProxyServer & ProxyPort: same as what you have set in network settings.

export http_proxy=http://<ProxyUserName>:<ProxyPass>@<ProxyServer>:<ProxyPort>
export https_proxy=http://<ProxyUserName>:<ProxyPass>@<ProxyServer>:<ProxyPort>

now I was able to login normally on firebase & deploy cloud functions. Hope it works

It works for me! Thanks. 😇

work for me! thanks

face the same issue

export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;export NO_PROXY=localhost,127.0.0.1

Thank you!

Hope this will help you:
[email protected]
it works on both win and mac with ssr

  1. find your proxy address

WeChatd29e8b5b594f8cff963da7441b84fbc9

  1. open "request.js" file in your firebase tools folder. for me, the path is
    /usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js
    use "npm root -g" to find your global npm path
  2. find the code below, about line 276
  if (!self.hasOwnProperty('proxy')) {
    self.proxy = getProxyFromURI(self.uri)
  }

change it to

  // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }
  self.proxy = "http://127.0.0.1:1087";  // this is your proxy address
  1. use firebase login --no-localhost
    IT WORKED

Hope this will help you:
[email protected]
it works on both win and mac with ssr

  1. find your proxy address

WeChatd29e8b5b594f8cff963da7441b84fbc9

  1. open "request.js" file in your firebase tools folder. for me, the path is
    /usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js
    use "npm root -g" to find your global npm path
  2. find the code below, about line 276
  if (!self.hasOwnProperty('proxy')) {
    self.proxy = getProxyFromURI(self.uri)
  }

change it to

  // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }
  self.proxy = "http://127.0.0.1:1087";  // this is your proxy address
  1. use firebase login --no-localhost
    IT WORKED

Just tested on Ubuntu 20.04, it works like a charm. Thank you for sharing!

Hope this will help you:
[email protected]
it works on both win and mac with ssr

  1. find your proxy address

WeChatd29e8b5b594f8cff963da7441b84fbc9

  1. open "request.js" file in your firebase tools folder. for me, the path is
    /usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js
    use "npm root -g" to find your global npm path
  2. find the code below, about line 276
  if (!self.hasOwnProperty('proxy')) {
    self.proxy = getProxyFromURI(self.uri)
  }

change it to

  // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }
  self.proxy = "http://127.0.0.1:1087";  // this is your proxy address
  1. use firebase login --no-localhost
    IT WORKED

Edit the proxy and run this command to auto hack the library:
sed -i '/self.tunnel*/i \ \ self.proxy = "http://192.168.219.7:9090";' /usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js

Hope this will help you:
[email protected]
it works on both win and mac with ssr

  1. find your proxy address

WeChatd29e8b5b594f8cff963da7441b84fbc9

  1. open "request.js" file in your firebase tools folder. for me, the path is
    /usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js
    use "npm root -g" to find your global npm path
  2. find the code below, about line 276
  if (!self.hasOwnProperty('proxy')) {
    self.proxy = getProxyFromURI(self.uri)
  }

change it to

  // if (!self.hasOwnProperty('proxy')) {
  //   self.proxy = getProxyFromURI(self.uri)
  // }
  self.proxy = "http://127.0.0.1:1087";  // this is your proxy address
  1. use firebase login --no-localhost

FINALLY WORKS!!! Thanks a ton!!!!🌷🌷🌷

Was this page helpful?
0 / 5 - 0 ratings