Web Service Port
Fix public Services that do not listen on the assigned port
A public Service must listen on 0.0.0.0 and the port Blossom supplies in
$PORT. Binding only to 127.0.0.1 or hardcoding another port prevents health
checks and public routing from reaching the process.
Symptoms
- the Service remains
startingorunhealthy - health checks report connection refused
- the application logs one listening port while the Service expects another
- the generated or custom Domain does not reach an otherwise successful Build
Diagnose
- Check the Service logs for its bind address and port.
- Confirm the Service command does not override
$PORT. - Open a Container shell with
blossom shellif the runtime needs interactive inspection. - Correct the application or Service command, then deploy a new Release.
Framework Examples
Node.js And Express
const port = process.env.PORT || 3000;
app.listen(port, "0.0.0.0");
Ruby And Rails
port ENV.fetch("PORT", 3000)
bind "tcp://0.0.0.0:#{ENV.fetch('PORT', 3000)}"
Python And Flask
import os
app.run(host="0.0.0.0", port=int(os.environ.get("PORT", 5000)))
Changing Domain settings does not fix an incorrect application bind. The Service contract is the stable fix.