Pivotal Knowledge Base

Follow

Failed to deploy NodeJS application to offline PCF environment due to network connection error

Environment 

Product Version
Pivotal Cloud Foundry® (PCF)  All versions

Symptom

When deploying a NodeJS application to the offline PCF® environment, staging tries to download Node or NPM (node package manager) package from  the Internet. It fails because there is no Internet connection available in the offline install. 

$ cf push <NODEJS_APP_NAME> -b nodejs_buildpack
Connected, dumping recent logs for app nodejs-sample in org MyOrg / 
space MySpace as admin...

2016-03-09T08:17:45.39+0530 [API/0] OUT Created app with guid 94F58297-11F7-42DA-BA06-2580135C2D5D 
2016-03-09T08:17:45.81+0530 [API/0] OUT Updated app with guid 94F58297-11F7-42DA-BA06-2580135C2D5D ({"route"=>"236c5559-4f1c-47a8-b7ed-eca3751bce12"}) 
2016-03-09T08:18:34.48+0530 [API/0] OUT Updated app with guid 94F58297-11F7-42DA-BA06-2580135C2D5D ({"state"=>"STARTED"}) 
... 
2016-03-09T08:18:34.53+0530 [STG/0] OUT Downloading nodejs_buildpack... 
2016-03-09T08:18:34.56+0530 [STG/0] OUT Downloaded nodejs_buildpack 
...
2016-03-09T08:18:34.58+0530 [STG/0] OUT Creating container 
2016-03-09T08:18:35.40+0530 [STG/0] OUT Successfully created container 
2016-03-09T08:18:35.40+0530 [STG/0] OUT Downloading app package... 
2016-03-09T08:18:37.28+0530 [STG/0] OUT Downloaded app package (7.7M) 
2016-03-09T08:18:37.28+0530 [STG/0] OUT Staging... 
2016-03-09T08:18:38.44+0530 [STG/0] OUT -------> Buildpack version 1.5.2 
2016-03-09T08:18:38.46+0530 [STG/0] OUT -----> Creating runtime environment
...
2016-03-09T08:18:38.47+0530 [STG/0] OUT -----> Installing binaries 
2016-03-09T08:18:38.48+0530 [STG/0] OUT engines.node (package.json):0.10.x 
2016-03-09T08:18:38.48+0530 [STG/0] OUT engines.npm (package.json):2.7.x 
2016-03-09T08:18:38.48+0530 [STG/0] OUT 
2016-03-09T08:18:38.49+0530 [STG/0] OUT Resolving node version 0.10.x via semver.io... 
2016-03-09T08:18:38.64+0530 [STG/0] OUT Downloading and installing node 0.10.38... 
2016-03-09T08:18:38.69+0530 [STG/0] OUT Downloaded [file:///tmp/buildpacks/dcf7e2354e9704fec2750759dbeb2928/dependencies/https___pivotal-buildpacks.s3.amazonaws.com_concourse-binaries_node_node-0.10.38-linux-x64.tar.gz] 
2016-03-09T08:18:39.07+0530 [STG/0] OUT Resolving npm version 2.7.xvia semver.io... 
2016-03-09T08:18:41.45+0530 [STG/0] OUT Downloading and installing npm 2.7.6 (replacing version 1.4.28)... 
2016-03-09T08:18:54.29+0530 [STG/0] OUT npm ERR! fetch failed https://registry.npmjs.org/npm/-/npm-2.7.6.tgz 
2016-03-09T08:19:04.31+0530 [STG/0] OUT npm ERR! fetch failed https://registry.npmjs.org/npm/-/npm-2.7.6.tgz 
2016-03-09T08:20:04.34+0530 [STG/0] OUT npm ERR! fetch failed https://registry.npmjs.org/npm/-/npm-2.7.6.tgz 
2016-03-09T08:20:04.34+0530 [STG/0] OUT npm ERR! network tunneling socket could not be established, cause=connect ECONNREFUSED 
2016-03-09T08:20:04.34+0530 [STG/0] OUT npm ERR! network This is most likely not a problem with npm itself 
2016-03-09T08:20:04.34+0530 [STG/0] OUT npm ERR! network and is related to network connectivity. 
2016-03-09T08:20:04.35+0530 [STG/0] OUT npm ERR! network In most cases you are behind a proxy or have bad network settings. 
2016-03-09T08:20:04.35+0530 [STG/0] OUT npm ERR! network 
2016-03-09T08:20:04.35+0530 [STG/0] OUT npm ERR! network If you are behind a proxy, please make sure that the 
2016-03-09T08:20:04.35+0530 [STG/0] OUT npm ERR! network 'proxy' config is set properly. See: 'npm help config' 
2016-03-09T08:20:04.35+0530 [STG/0] OUT 
2016-03-09T08:20:04.35+0530 [STG/0] OUT npm ERR! System Linux 3.19.0-49-generic 
2016-03-09T08:20:04.35+0530 [STG/0] OUT npm ERR! command "/tmp/app/. 
heroku/node/bin/node" "/tmp/app/.heroku/node/bin/npm" "install" "--unsafe-perm" 
"--quiet" "-g" "npm@2.7.6" 
2016-03-09T08:20:04.35+0530 [STG/0] OUT npm ERR! cwd /tmp/app 
2016-03-09T08:20:04.35+0530 [STG/0] OUT npm ERR! node -v v0.10.38 
2016-03-09T08:20:04.35+0530 [STG/0] OUT npm ERR! npm -v 1.4.28 
2016-03-09T08:20:04.35+0530 [STG/0] OUT npm ERR! code ECONNRESET 
2016-03-09T08:20:04.35+0530 [STG/0] OUT npm ERR! 
2016-03-09T08:20:04.35+0530 [STG/0] OUT npm ERR! Additional logging details can be found in: 
2016-03-09T08:20:04.35+0530 [STG/0] OUT npm ERR! /tmp/app/npm-debug.log 
2016-03-09T08:20:04.35+0530 [STG/0] OUT npm ERR! not ok code 0 
2016-03-09T08:20:04.36+0530 [STG/0] OUT -----> Build failed 
2016-03-09T08:20:04.37+0530 [STG/0] OUT 
2016-03-09T08:20:04.37+0530 [STG/0] OUT We're sorry this build is fa iling! You can troubleshoot common issues here: 
2016-03-09T08:20:04.37+0530 [STG/0] OUT https://devcenter.heroku.com/articles/troubleshooting-node-deploys 
2016-03-09T08:20:04.37+0530 [STG/0] OUT 
2016-03-09T08:20:04.37+0530 [STG/0] OUT Some possible problems: 
2016-03-09T08:20:04.37+0530 [STG/0] OUT 
2016-03-09T08:20:04.37+0530 [STG/0] OUT - node_modules checked into source control 
2016-03-09T08:20:04.37+0530 [STG/0] OUT https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git 
2016-03-09T08:20:04.37+0530 [STG/0] OUT 
2016-03-09T08:20:04.38+0530 [STG/0] ERR Failed to compile droplet 
2016-03-09T08:20:04.38+0530 [STG/0] OUT Exit status 223 
2016-03-09T08:20:04.38+0530 [STG/0] ERR Staging failed: Exited with status 223 
2016-03-09T08:20:04.46+0530 [API/0] ERR Failed to stage application: staging failed 

Cause

The Cloud Foundry NodeJS (offline) Buildpack does not package all versions of Node and NPM binaries. It usually includes the latest two Node minor versions of each major release. 

For example, the NodeJS Offline Buildpack v1.5.15 supports the Node versions listed in the table below:

nameversionscf_stacks
node 0.10.44 cflinuxfs2
node 0.10.45 cflinuxfs2
node 0.12.13 cflinuxfs2
node 0.12.14 cflinuxfs2
node 4.4.4 cflinuxfs2
node 4.4.5 cflinuxfs2
node 5.10.1 cflinuxfs2
node 5.11.1 cflinuxfs2
node 6.2.0 cflinuxfs2
node 6.2.1 cflinuxfs2

Besides the Node releases, there are limited NPM binary packages in each offline buildpack.

Resolution
Configure your NodeJS application with Node releases supported by the Cloud Foundry NodeJS  Buildpack when deploying it to offline PCF environment. As an example, when using above NodeJS Buildpack v1.5.15, configure its Node engine in the engines section of the package.json, so that it looks like the following: 

{
  "name": "nodejs-sample",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node app.js"
  },
  "dependencies": {
    "package1": "*",
    "package2": "*"
  },
  "engines": {
    "node": "6.2.1"
  }
}

We recommend leaving the NPM version out. This is because the version of NPM you put in the package.json must match the version shipped with the version of Node that you have selected. Any minor mistakes with NPM version will cause Internet access. 

As another option, simply leave the Node/NPM versions as empty so that the buildpack automatically chooses the appropriate version.

Additional Information
For further details of the Node/NPM release list, please click here.

Comments

Powered by Zendesk