Can't publish packages anymore - 502 Bad Gateway #4828

Closed
pocesar opened this Issue Mar 3, 2014 · 14 comments

Projects

None yet

7 participants

@pocesar
pocesar commented Mar 3, 2014

I can't publish packages anymore, since I've updated npm and node:

2 info using npm@1.4.4
3 info using node@v0.10.26
4 verbose node symlink C:\nodejs\\node.exe
// ...
380 verbose url raw promised-jugglingdb
381 verbose url resolving [ 'https://registry.npmjs.org/', './promised-jugglingdb' ]
382 verbose url resolved https://registry.npmjs.org/promised-jugglingdb
383 info trying registry request attempt 1 at 04:45:13
384 http PUT https://registry.npmjs.org/promised-jugglingdb
385 http 502 https://registry.npmjs.org/promised-jugglingdb
386 verbose bad json <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
386 verbose bad json <html><head>
386 verbose bad json <title>502 Bad Gateway</title>
386 verbose bad json </head><body>
386 verbose bad json <h1>Bad Gateway</h1>
386 verbose bad json <p>The proxy server received an invalid
386 verbose bad json response from an upstream server.<br />
386 verbose bad json </p>
386 verbose bad json <p>Additionally, a 400 Bad Request
386 verbose bad json error was encountered while trying to use an ErrorDocument to handle the request.</p>
386 verbose bad json </body></html>
387 error registry error parsing json

it then tries 2 more times then dies. happening to all my packages.

@pocesar
pocesar commented Mar 3, 2014

the password was wrong in my npmrc file. the error is non-descriptive, should have given me a 403 instead, I would have re-created the file much faster...

@isaacs
Member
isaacs commented Mar 4, 2014

Someone else mentioned that they got this 502 instead of a 401/403 yesterday. However, in my tests, I'm always getting the (correct) 401 error in this case. We'll continue digging into it. Sorry about the confusing error!

@pocesar
pocesar commented Mar 4, 2014

np @isaacs thanks for getting back.

@basarat
basarat commented Jun 22, 2014

I got the same thing today.

image

Deleting the auth section from my user .npmrc followed by npm adduser fixed it

@MandarinConLaBarba

Had a similar problem just now, but w/ the json parse error preceding the 502.

npm ERR! registry error parsing json
npm ERR! registry error parsing json
npm ERR! registry error parsing json
npm ERR! publish Failed PUT 502
npm ERR! SyntaxError: Unexpected token <
npm ERR! <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
npm ERR! <html><head>
npm ERR! <title>502 Bad Gateway</title>
npm ERR! </head><body>
npm ERR! <h1>Bad Gateway</h1>
npm ERR! <p>The proxy server received an invalid
npm ERR! response from an upstream server.<br />
npm ERR! </p>
npm ERR! </body></html>
npm ERR! 
npm ERR!     at Object.parse (native)
npm ERR!     at RegClient.<anonymous> (/Users/mandarin/nvm/v0.10.29/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:240:23)
npm ERR!     at Request._callback (/Users/mandarin/nvm/v0.10.29/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:212:65)
npm ERR!     at Request.self.callback (/Users/mandarin/nvm/v0.10.29/lib/node_modules/npm/node_modules/request/request.js:123:22)
npm ERR!     at Request.emit (events.js:98:17)
npm ERR!     at Request.<anonymous> (/Users/mandarin/nvm/v0.10.29/lib/node_modules/npm/node_modules/request/request.js:893:14)
npm ERR!     at Request.emit (events.js:117:20)
npm ERR!     at IncomingMessage.<anonymous> (/Users/mandarin/nvm/v0.10.29/lib/node_modules/npm/node_modules/request/request.js:844:12)
npm ERR!     at IncomingMessage.emit (events.js:117:20)
npm ERR!     at _stream_readable.js:929:16
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Darwin 13.3.0
npm ERR! command "/Users/mandarin/nvm/v0.10.29/bin/node" "/Users/mandarin/nvm/v0.10.29/bin/npm" "publish" "react-datepicker/"
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! type unexpected_token
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR! not ok code 0

Doing an npm login fixed it. Not sure what was in .npmrc that was unsavory to npm.

@othiym23
Collaborator

Closing as resolved, although we still need to figure out why our CDN is returning the errant status code (this still happens intermittenly).

@othiym23 othiym23 closed this Sep 21, 2014
@Pomax
Pomax commented Oct 4, 2014

regression - I am seeing this issue again after having changed my password on one machine, and tried to npm publish on another with outdated stored credentials. Instead of an immediate auth rejection, npm keeps trying to publish and after several minutes dies with

npm ERR! registry error parsing json
npm ERR! registry error parsing json
npm ERR! registry error parsing json
npm ERR! publish Failed PUT 502
npm ERR! SyntaxError: Unexpected token <
npm ERR! <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
npm ERR! <html><head>
npm ERR! <title>502 Bad Gateway</title>
npm ERR! </head><body>
npm ERR! <h1>Bad Gateway</h1>
npm ERR! <p>The proxy server received an invalid
npm ERR! response from an upstream server.<br />
npm ERR! </p>
npm ERR! </body></html>
npm ERR!
npm ERR!     at Object.parse (native)
npm ERR!     at RegClient.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\req
uest.js:266:23)
npm ERR!     at Request._callback (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request
.js:238:65)
npm ERR!     at Request.self.callback (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:123:22)
npm ERR!     at Request.emit (events.js:98:17)
npm ERR!     at Request.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:893:14)
npm ERR!     at Request.emit (events.js:117:20)
npm ERR!     at IncomingMessage.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:84
4:12)
npm ERR!     at IncomingMessage.emit (events.js:117:20)
npm ERR!     at _stream_readable.js:938:16
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js"
 "publish"
npm ERR! cwd C:\Users\Mike\Documents\Git projects\released\node-flickrapi
npm ERR! node -v v0.10.30
npm ERR! npm -v 1.4.21
npm ERR! type unexpected_token
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\Mike\Documents\Git projects\released\node-flickrapi\npm-debug.log
npm ERR! not ok code 0
@othiym23
Collaborator
othiym23 commented Oct 4, 2014

@pomax You need to log in again (and probably clear out the _auth / _password lines from $HOME/.npmrc by hand – see #6255). We need to fix #6255 and also straighten out whatever causes the CDN to return an HTML 502 page when the Couch app returns a 401 JSON response.

@basarat
basarat commented Oct 5, 2014

@Pomax the simplest solution I have found is simply run npm login and you don't need to mess with any config files

@Pomax
Pomax commented Oct 5, 2014

yes obviously, but I had to first realise that's what was wrong, I changed it long ago enough that I didn't even remember I had a new password, so that npm error is just a giant red herring =)

Instead of trying to keep logging in, it should just throw back a 403 instead, not a "502 bad gateway"

@basarat
basarat commented Oct 6, 2014

Instead of trying to keep logging in, it should just throw back a 403 instead, not a "502 bad gateway"

👍

@jhoguet jhoguet pushed a commit to DealerDotCom/jasmine-cucumber that referenced this issue Oct 17, 2014
Jon Hoguet npm publish failed pushing 1.0.1 so had to tick to 1.0.2 re: npm/npm#… 622562e
@gregjacobs

Just had the same problem. Had changed my password on npmjs.org, but hadn't re-logged in from the command line. When trying to publish a package, I got the "502 bad gateway." Would have been much more helpful to know that my password was no longer valid.

@othiym23 othiym23 added the support label Nov 10, 2014
@othiym23
Collaborator

To all pointing out that the registry should be returning 403 instead of 502: agreed. Unfortunately, this is a result of how our CDN is configured, and while tweaking the cache configuration has been on the npm team's to-do list for a while, it still hasn't reached high priority due to it not being something actually being on fire (and because tweaking Varnish's configuration files is complicated and risky, a bad combination).

@ghost
ghost commented May 20, 2015

I had this error after adding a user to the module (my personnal account). I did a npm login from the new account and that worked.

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