Container eviction

Anybody elses containers being consistently being evicted after approx 2 minutes? I'm starting up a container manually using the start method so that I can provide a JOB_ID environment variable to the container. The job starts up and begins processing for roughly 2 minutes before dying? Is this normal? Btw I'm setting the sleepAfter option to 24h
5 Replies
sampotter
sampotterOP2mo ago
When running the containers locally I am seeing two errors
✘ [ERROR] Error checking if container is ready: connect(): Connection refused: container port not found. Make sure you exposed the port in your container definition.


✘ [ERROR] Error checking if container is ready: The operation was aborted
✘ [ERROR] Error checking if container is ready: connect(): Connection refused: container port not found. Make sure you exposed the port in your container definition.


✘ [ERROR] Error checking if container is ready: The operation was aborted
But that error also occurs for some of the example containers Like https://github.com/cloudflare/containers/tree/main/example-node So I'm not sure if it's related to my specific issue? My container definition is
import { Container } from "@cloudflare/containers";

export class Backfill extends Container {
defaultPort = 8080;

// Time before container sleeps due to inactivity
sleepAfter = "24h";

// So that we can pass a BACKFILL_ID to the container
manualStart = true;

override onStart() {
console.log("Container successfully started");
}

override onStop() {
console.log("Container successfully shut down");
}

override onError(error: unknown) {
console.log("Container error:", error);
}

async fetch(request: Request): Promise<Response> {
return this.containerFetch(request, 8080);
}
}
import { Container } from "@cloudflare/containers";

export class Backfill extends Container {
defaultPort = 8080;

// Time before container sleeps due to inactivity
sleepAfter = "24h";

// So that we can pass a BACKFILL_ID to the container
manualStart = true;

override onStart() {
console.log("Container successfully started");
}

override onStop() {
console.log("Container successfully shut down");
}

override onError(error: unknown) {
console.log("Container error:", error);
}

async fetch(request: Request): Promise<Response> {
return this.containerFetch(request, 8080);
}
}
Wrangler definition is
{
"name": "api",
"workers_dev": false,
"preview_urls": false,
"main": "src/main.ts",
"compatibility_date": "2025-05-23",
"compatibility_flags": ["nodejs_compat"],
"dev": {
"port": 3001
},
"observability": {
"logs": {
"enabled": true
}
},
"vars": {
"LOG": "debug",
"ENVIRONMENT": "development"
},
"containers": [
{
"name": "api",
"max_instances": 10,
"class_name": "Backfill",
"image": "registry.cloudflare.com/92ffbc939210458a0ef3f107c5c54d96/backfill:0.0.11"
}
],
"durable_objects": {
"bindings": [
{
"name": "BACKFILL",
"class_name": "Backfill"
}
]
},
"migrations": [
{
"tag": "v1",
"new_sqlite_classes": ["Backfill"]
}
]
}
{
"name": "api",
"workers_dev": false,
"preview_urls": false,
"main": "src/main.ts",
"compatibility_date": "2025-05-23",
"compatibility_flags": ["nodejs_compat"],
"dev": {
"port": 3001
},
"observability": {
"logs": {
"enabled": true
}
},
"vars": {
"LOG": "debug",
"ENVIRONMENT": "development"
},
"containers": [
{
"name": "api",
"max_instances": 10,
"class_name": "Backfill",
"image": "registry.cloudflare.com/92ffbc939210458a0ef3f107c5c54d96/backfill:0.0.11"
}
],
"durable_objects": {
"bindings": [
{
"name": "BACKFILL",
"class_name": "Backfill"
}
]
},
"migrations": [
{
"tag": "v1",
"new_sqlite_classes": ["Backfill"]
}
]
}
ralphjsmit
ralphjsmit2mo ago
I am getting this issue locally as well.
Browsershot container successfully shut down
✘ [ERROR] Error checking if container is ready: connect(): Connection refused: container port not found. Make sure you exposed the port in your container definition.


✘ [ERROR] Error checking if container is ready: The operation was aborted


Port 3000 is ready
Browsershot container successfully started
▲ [WARNING] workerd/io/actor-sqlite.c++:647: warning: NOSENTRY SQLite alarm handler canceled with requestScheduledAlarm.; scheduledTime = 1752061509.223s; localAlarmState.orDefault(kj::UNIX_EPOCH) = 1752061511.331s; actorId = 4c18d91ed32e76baaea73184b2449e982773db4f5d86eeab28d2a65bc35ddfb5
Browsershot container successfully shut down
✘ [ERROR] Error checking if container is ready: connect(): Connection refused: container port not found. Make sure you exposed the port in your container definition.


✘ [ERROR] Error checking if container is ready: The operation was aborted


Port 3000 is ready
Browsershot container successfully started
▲ [WARNING] workerd/io/actor-sqlite.c++:647: warning: NOSENTRY SQLite alarm handler canceled with requestScheduledAlarm.; scheduledTime = 1752061509.223s; localAlarmState.orDefault(kj::UNIX_EPOCH) = 1752061511.331s; actorId = 4c18d91ed32e76baaea73184b2449e982773db4f5d86eeab28d2a65bc35ddfb5
sampotter
sampotterOP2mo ago
Yeh could be happening because Cloudflare isn't detecting the container successfully launched After some more testing it looks like if the container is restarted after the initial eviction. It will then operate as normal and "never" be evicted @John Spurlock @Isaac | AS213339 How do you guys work around this limitation? Is this intended behaviour?
Isaac McFadyen
Isaac McFadyen2mo ago
?pings
SuperHelpflare
SuperHelpflare2mo ago
Please do not ping community members for non-moderation reasons. Doing so will not solve your issue faster and will make people less likely to want to help you.

Did you find this page helpful?