hibiken/asynq · error

queue not found

Error message

queue not found

What it means

ErrQueueNotFound indicates the specified queue does not exist in Redis. Inspector operations (DeleteQueue, GetTaskInfo, List*Tasks) translate the internal redis queue-not-found error into this sentinel, often with the queue name appended.

Solutions

  1. Verify the queue name matches the one used in asynq.Config queues and Enqueue calls.
  2. Ensure the inspector connects to the same Redis instance/DB as the producer.
  3. Enqueue a task (or check application flow) so the queue gets created before inspecting it.
  4. Handle errors.Is(err, asynq.ErrQueueNotFound) as a non-fatal 'nothing to do' case.

Example fix

// before
if err := insp.DeleteQueue("dead_letter", false); err != nil { log.Fatal(err) }
// after
err := insp.DeleteQueue("dead_letter", false)
if errors.Is(err, asynq.ErrQueueNotFound) {
    log.Println("queue does not exist; nothing to delete")
} else if err != nil {
    log.Fatal(err)
}
Defensive patterns

Strategy: type-guard

Validate before calling

// Pre-check queue existence:
_, err := insp.Stats(qname)
exists := !errors.Is(err, asynq.ErrQueueNotFound)

Type guard

func isQueueNotFound(err error) bool { return errors.Is(err, asynq.ErrQueueNotFound) }

Try / catch

err := insp.DeleteQueue(q, false)
if isQueueNotFound(err) { return nil }
if err != nil { return err }

Prevention

When it happens

Trigger: inspector.DeleteQueue(q, force) on a queue never created or already deleted; inspector.GetTaskInfo/ListPendingTasks on a queue name that has no stats key; typo'd queue name.

Common situations: Queues are created lazily on first enqueue, so inspecting a brand-new queue before any task exists; environment mismatch (inspecting against a different Redis DB than the producer); queue renamed in config.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of hibiken/asynq@d135f1439b (2026-09-07). Data as JSON: /api/errors/23d056c56584788c. Report an issue: GitHub.

Appendix: source

Thrown at inspector.go:207

	stats, err := i.rdb.HistoricalStats(queue, n)
	if err != nil {
		return nil, err
	}
	var res []*DailyStats
	for _, s := range stats {
		res = append(res, &DailyStats{
			Queue:     s.Queue,
			Processed: s.Processed,
			Failed:    s.Failed,
			Date:      s.Time,
		})
	}
	return res, nil
}

var (
	// ErrQueueNotFound indicates that the specified queue does not exist.
	ErrQueueNotFound = errors.New("queue not found")

	// ErrQueueNotEmpty indicates that the specified queue is not empty.
	ErrQueueNotEmpty = errors.New("queue is not empty")

	// ErrTaskNotFound indicates that the specified task cannot be found in the queue.
	ErrTaskNotFound = errors.New("task not found")
)

// DeleteQueue removes the specified queue.
//
// If force is set to true, DeleteQueue will remove the queue regardless of
// the queue size as long as no tasks are active in the queue.
// If force is set to false, DeleteQueue will remove the queue only if
// the queue is empty.
//
// If the specified queue does not exist, DeleteQueue returns ErrQueueNotFound.
// If force is set to false and the specified queue is not empty, DeleteQueue
// returns ErrQueueNotEmpty.

View on GitHub (pinned to d135f1439b)