Cloud Foundry application deployment fails due to EHOSTUNREACH error
Cloud Foundry application deployment fails due to EHOSTUNREACH
error.
Symptoms
When you deploy a Cloud Foundry application, an error similar to the following message is displayed:
-----> Building dependencies
Installing node modules (package.json)
npm ERR! Linux 4.4.0-75-generic
npm ERR! argv "/tmp/app/vendor/node/bin/node" "/tmp/app/vendor/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/app/.npmrc"
npm ERR! node v6.12.2
npm ERR! npm v3.10.10
npm ERR! code EHOSTUNREACH
npm ERR! errno EHOSTUNREACH
npm ERR! syscall connect
npm ERR! connect EHOSTUNREACH 151.101.40.162:443
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /tmp/app/npm-debug.log
-----> Build failed
Some possible problems:
- Node version not specified in package.json
http://docs.cloudfoundry.org/buildpacks/node/node-tips.html
Failed to compile droplet
Exit status 223
Staging failed: Exited with status 223
Destroying container
Successfully destroyed container
FAILED
Error restarting application: BuildpackCompileFailed
In this message, the failed application or buildpack that is used by the application is trying to access the Internet to download content. If you require the use of an HTTP proxy to reach the Internet, you must configure your application to use the proxy.
Resolving the problem
- Log in to Cloud Foundry:
cf login
-
Change to the organization and space where the application is deployed:
cf target -o <org> -s <space>
-
Set the HTTP proxy variables for the application. For example, if your proxy is
http://myproxy.com:3128
, run the following command:cf set-env myApp https_proxy "http://myproxy.com:3128" cf set-env myApp http_proxy "http://myproxy.com:3128"
-
Restart the application. Run the following command:
cf restart myApp