Node.js2 minutes to read

Fix a Node.js API that starts but is unreachable over HTTPS

Test a known route, check the listener address and assigned port, then isolate a routing failure from a DNS or deployment problem.

Send a request with a known response

A “listening” message tells you a process opened a socket. To find out whether a visitor can reach it, use the HTTPS address from the deployment’s Settings and a route you know exists. For the Node.js API example, the contract is a GET request to the root path with a JSON response containing node-api. A request to /health returns 404 on that same healthy application.

Set APP_URL in your local shell to the copied platform origin. Use a GET request so you exercise the same handler as a visitor. The starter only implements GET, so a HEAD probe such as curl -I gives a different result.

Check the response headers and body
curl --include --max-time 10 "$APP_URL/"

Inspect the actual start command

In Variables, check MAIN_FILE and any RUN_COMMAND. The HTTP starter needs index.mjs. If a custom command is set, read the package script it invokes and follow it through to the file that calls listen. A development server can default to loopback or a fixed port that works on a laptop but sits outside the ingress path.

Listener for an existing Node HTTP server
const port = Number(process.env.SERVER_PORT)
server.listen(port, '0.0.0.0', () => console.log('Listening on', port))

Save the changed file or deploy the corrected branch. Restart for a manual file edit. Check the new startup timestamp, then repeat the same GET on the platform hostname. If the process exits after the start message, read the following error before changing network settings.

Work outward from the first passing check

  • Expected JSON at the platform URL. The request reached the correct app. If your own domain still fails, check the CNAME, ownership proof and certificate for that hostname.
  • App-generated 404. Compare method, path and any framework route prefix. In this example, a successful root response plus an empty 404 on another path shows that HTTP is reaching the worker.
  • No usable response at either address. Confirm the HTTP profile, running state, listener port and active revision. Test the platform hostname again before adding a proxy or new DNS records.

Once the URL works, keep a small read-only endpoint with a distinctive response for future deploy checks. For platform and custom hostname setup, see HTTPS and custom domains.