Build Fails when trying to get system ENV Variables

Posted November 1, 2020 3.4k views
Node.jsGraphQLDigitalOcean App Platform

I’m attempting to use the App platform to deploy a GraphQL API made with Apollo Server as a web service. When Adding in System ENV vars, I get this error message:

Error: getaddrinfo ENOTFOUND
osdm-api | 08:46:54     at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)
osdm-api | 08:46:54 Emitted 'error' event on Server instance at:
osdm-api | 08:46:54     at GetAddrInfoReqWrap.doListen [as callback] (net.js:1499:12)
osdm-api | 08:46:54     at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:17) {
osdm-api | 08:46:54   errno: 'ENOTFOUND',
osdm-api | 08:46:54   code: 'ENOTFOUND',
osdm-api | 08:46:54   syscall: 'getaddrinfo',
osdm-api | 08:46:54   hostname: ''
osdm-api | 08:46:54 }

I’m using $self.PUBLICURL to grab the URL at build time. I’m able to get PRIVATEPORT & PUBLICROUTE_PATH without any issue.

edited by KFSys

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

It looks like you’re application code is trying to run a getaddrinfo call against the string “”. getaddrinfo expects a clean hostname (without the https:// prefix and /api route). You may want the ${APP_DOMAIN} binding instead of $APP_URL or ${service.PUBLIC_URL}.

If you’re trying to determine which addressed to bind your service to, you should be able to use “$PORT” which listens on all interfaces, and selects the port based on the $PORT variable which is passed in.