# Port Binding Failures

> Diagnose applications failing to bind or binding to the incorrect interface.

- **Category**: Troubleshoot
- **Last Verified**: 2026-07-14

## Symptom

The deployment fails with error code `PORT_MISMATCH` or `CONTAINER_CRASH_LOOP`. The logs show the server started but the deployment timed out after 5 minutes.

## What it means

Kubeletto could not reach your container. A Knative endpoint requires listening on all host interfaces (`0.0.0.0`) on the port allocated in the system configuration.

## Most likely causes

- Hardcoding the port inside your application code (e.g. `app.listen(3000)`) instead of checking `$PORT`.
- Binding to the local interface `127.0.0.1` or `localhost`, making the container unreachable from the external host network.

## How to diagnose it

Check your application logs. Ensure you see standard startup lines showing binding actions:

```bash
kubeletto logs my-service --tail 100
```

## How to fix it

Modify your startup code to read the environment variable `PORT` and bind to `0.0.0.0`. Example in Node.js:

```javascript
const port = process.env.PORT || 8080;
app.listen(port, "0.0.0.0", () => {
  console.log(`Server running on port ${port}`);
});
```

