Skip to main content
This page describes common issues and how to troubleshoot them.

Preview URLs return a 502 server error

This error occurs when the server running inside the sandbox is binding to localhost. As a result, it is only reachable inside the sandbox; the external preview URL will not be able to access it. To resolve this error, configure your server to bind to IP address 0.0.0.0, so that it listens on all available network interfaces. To avoid IPv4/IPv6 compatibility issues, we recommend using the environment variable BL_SERVER_HOST instead of setting the address to a static value. For example, in code:
const host = process.env.BL_SERVER_HOST || '0.0.0.0';
app.listen(3000, host, () => {
  console.log(`Server is running`);
});
or at the command line:
npm serve -- -host 0.0.0.0

Deployment fails with STARTUP TCP probe failed or DEADLINE_EXCEEDED error

This error occurs when the server running inside the sandbox is not binding to the correct host and port. To resolve this error, configure your server to bind to the host and port designated by the BL_SERVER_HOST and BL_SERVER_PORT environment variables. Blaxel automatically injects these variables during deployment. For example:
const port = parseInt(env.BL_SERVER_PORT || "80");
const host = process.env.BL_SERVER_HOST || "0.0.0.0";
app.listen(port, host, () => {
  console.log(`Server is running`);
});