gofiber/fiber · error
fiber: no view engine configured
Error message
fiber: no view engine configured
What it means
ErrNoViewEngineConfigured is returned by App.ReloadViews (app.go:937) when no application in the mount tree has a non-nil config.Views at the time of the call. The fiber/v3 Render path does NOT return this error; it surfaces only from ReloadViews, which iterates the mounted apps, invokes Load on each non-nil engine, and reports the sentinel if none was found.
Solutions
- Install the engine first: app := fiber.New(fiber.Config{Views: engine.New(./views, ".tmpl")}).
- If you must defer engine setup, assign app.config.Views before calling ReloadViews.
- Guard the call: if app.Config().Views != nil { _ = app.ReloadViews() }.
Example fix
// before
if err := app.ReloadViews(); err != nil {
log.Fatal(err)
}
// after
app := fiber.New(fiber.Config{Views: html.New("./views", ".html")})
if err := app.ReloadViews(); err != nil {
log.Fatal(err)
} Defensive patterns
Strategy: validation
Validate before calling
// Guard ReloadViews so it only runs when an engine is configured.
func reloadSafely(app *fiber.App) error {
if app == nil || app.Config().Views == nil {
return nil
}
return app.ReloadViews()
} Try / catch
if err := app.ReloadViews(); err != nil {
if errors.Is(err, fiber.ErrNoViewEngineConfigured) {
log.Printf("reload skipped: no view engine configured")
return nil
}
return err
} Prevention
- Install the view engine at construction: fiber.New(fiber.Config{Views: engine.New(...)}).
- Guard ReloadViews with a non-nil check on app.Config().Views.
- In mounted setups, confirm at least one sub-app has an engine before calling ReloadViews.
When it happens
Trigger: Calling app.ReloadViews() when config.Views was never set (New(Config{Views: ...}) was not used, or app has no mounted sub-app with an engine). The reloaded flag in app.go:920-933 stays false and the function returns ErrNoViewEngineConfigured.
Common situations: Calling ReloadViews in a hot-reload hook before installing the engine; setting Views on a sub-app but calling ReloadViews on the parent before mounting; removing the engine during reconfiguration and forgetting to restore it.
Related errors
- failed to render
- fiber: failed to reload views
- add: invalid http method
- basicauth: charset must be UTF-8
- binder: custom binder not found, please be sure to enter…
AI-assisted analysis of gofiber/fiber@a105acad6c (2026-08-11).
Data as JSON: /api/errors/c983264731bbb8d6.
Report an issue: GitHub.
Appendix: source
Thrown at error.go:22
"encoding/json"
"errors"
"github.com/gofiber/schema"
)
// Wrap and return this for unreachable code if panicking is undesirable (i.e., in a handler).
// Unexported because users will hopefully never need to see it.
var errUnreachable = errors.New("fiber: unreachable code, please create an issue at github.com/gofiber/fiber")
// General errors
var (
ErrGracefulTimeout = errors.New("shutdown: graceful timeout has been reached, exiting")
// ErrNotRunning indicates that a Shutdown method was called when the server was not running.
ErrNotRunning = errors.New("shutdown: server is not running")
// ErrHandlerExited is returned by App.Test if a handler panics or calls runtime.Goexit().
ErrHandlerExited = errors.New("runtime.Goexit() called in handler or server panic")
// ErrNoViewEngineConfigured indicates that a helper requiring a view engine was invoked without one configured.
ErrNoViewEngineConfigured = errors.New("fiber: no view engine configured")
// ErrAutoCertWithCertFile indicates AutoCertManager cannot be used with CertFile/CertKeyFile.
ErrAutoCertWithCertFile = errors.New("tls: AutoCertManager cannot be combined with CertFile/CertKeyFile")
// ErrRouteNotRepresentable indicates a route whose path no relative URL can
// name, so Route.URL, GetRouteURL and Redirect().Route cannot compose one.
// A path starting with two or more slashes is such a route: the URL that
// would reach it opens an authority instead.
ErrRouteNotRepresentable = errors.New("router: route path cannot be expressed as a relative URL")
)
// Fiber redirection errors
var (
ErrRedirectBackNoFallback = NewError(StatusInternalServerError, "Referer not found, you have to enter fallback URL for redirection.")
)
// Range errors
var (
// ErrRangeMalformed is returned for a syntactically invalid Range header,
// which RFC 9110 Section 14.2 allows a server to reject; it carries aView on GitHub (pinned to a105acad6c)