Skip to main content
Version: 4.0.0

Configuration reference

Every configuration option Serverpod's core library reads. Options come from three sources: the config/<run-mode>.yaml files, environment variables, and the ServerpodConfig Dart object. Environment variables override the YAML files. If you pass a ServerpodConfig to the Serverpod constructor, the server ignores the YAML files and environment variables. Command-line options such as --mode still override the values in your ServerpodConfig. For how to choose between them, see Configuration.

Run options

Set the run mode, server role, and boot behavior. Declare each per run mode in the matching config/<mode>.yaml, or as an environment variable.

Environment variableCommand line optionConfig file optionDefaultDescription
SERVERPOD_RUN_MODE--modeN/AdevelopmentConfigures the mode of the server instance. Valid options are development, staging, production and test.
SERVERPOD_SERVER_ID--server-idserverIddefaultConfigures the id of the server instance.
SERVERPOD_SERVER_ROLE--rolerolemonolithConfigures the role of the server instance. Valid options are monolith, serverless and maintenance.
SERVERPOD_LOGGING_MODE--loggingloggingnormalConfigures the logging level. Valid options are normal, and verbose.
SERVERPOD_APPLY_MIGRATIONS--apply-migrationsapplyMigrationsfalseConfigures if migrations should be applied when the server starts.
SERVERPOD_APPLY_REPAIR_MIGRATION--apply-repair-migrationapplyRepairMigrationfalseConfigures if repair migrations should be applied when the server starts.

Server and services

Ports, hosts, and connection settings for the API, Insights, and web servers, the database, Redis, session logs, and future calls, plus a few options that exist only on the Dart config object or as environment variables.

Environment variableConfig fileDefaultDescription
SERVERPOD_API_SERVER_PORTapiServer.port8080The port number for the API server
SERVERPOD_API_SERVER_PUBLIC_HOSTapiServer.publicHostlocalhostThe public host address of the API server
SERVERPOD_API_SERVER_PUBLIC_PORTapiServer.publicPort8080The public port number for the API server
SERVERPOD_API_SERVER_PUBLIC_SCHEMEapiServer.publicSchemehttpThe public scheme (http/https) for the API server
SERVERPOD_INSIGHTS_SERVER_PORTinsightsServer.port-The port number for the Insights server
SERVERPOD_INSIGHTS_SERVER_PUBLIC_HOSTinsightsServer.publicHost-The public host address of the Insights server
SERVERPOD_INSIGHTS_SERVER_PUBLIC_PORTinsightsServer.publicPort-The public port number for the Insights server
SERVERPOD_INSIGHTS_SERVER_PUBLIC_SCHEMEinsightsServer.publicScheme-The public scheme (http/https) for the Insights server
SERVERPOD_INSIGHTS_SERVER_ENABLE_DATABASE_ACCESSinsightsServer.enableDatabaseAccessfalseWhether the Insights server serves the direct database access endpoints (used by custom service client tooling, not the Insights app)
SERVERPOD_WEB_SERVER_PORTwebServer.port-The port number for the Web server
SERVERPOD_WEB_SERVER_PUBLIC_HOSTwebServer.publicHost-The public host address of the Web server
SERVERPOD_WEB_SERVER_PUBLIC_PORTwebServer.publicPort-The public port number for the Web server
SERVERPOD_WEB_SERVER_PUBLIC_SCHEMEwebServer.publicScheme-The public scheme (http/https) for the Web server
SERVERPOD_WEB_SERVER_STATIC_CACHE_CONTROLN/A-The Cache-Control header for StaticRoute responses without a cacheControlFactory. See Static files.
SERVERPOD_WEB_SERVER_SPA_CACHE_CONTROLN/A-The Cache-Control header for SpaRoute responses without a cacheControlFactory. Never applies to the fallback file. See Single-page apps.
SERVERPOD_WEB_SERVER_FLUTTER_CACHE_CONTROLN/A-The Cache-Control header for FlutterRoute responses without a cacheControlFactory. See Flutter web.
SERVERPOD_DATABASE_HOSTdatabase.host-The host address of the database
SERVERPOD_DATABASE_PORTdatabase.port-The port number for the database connection
SERVERPOD_DATABASE_NAMEdatabase.name-The name of the database
SERVERPOD_DATABASE_USERdatabase.user-The user name for database authentication
SERVERPOD_DATABASE_SEARCH_PATHSdatabase.searchPaths-The search paths used for all database connections
SERVERPOD_DATABASE_REQUIRE_SSLdatabase.requireSslfalseIndicates if SSL is required for the database
SERVERPOD_DATABASE_IS_UNIX_SOCKETdatabase.isUnixSocketfalseSpecifies if the database connection is a Unix socket
SERVERPOD_DATABASE_MAX_CONNECTION_COUNTdatabase.maxConnectionCount10The maximum number of connections in the database pool. Set to 0 or a negative value for unlimited connections.
N/Adatabase.filePath-The SQLite database file path. Set this instead of host/port/name/user when using SQLite. Config file only.
N/Adatabase.dialectInferredThe database dialect. Valid options are postgres and sqlite. When unset, a filePath selects SQLite, and host/port/name/user select PostgreSQL. Config file only.
SERVERPOD_DATABASE_DATA_PATHdatabase.dataPath-Directory for the embedded PostgreSQL cluster, relative to the server package unless absolute. When set, Serverpod starts or attaches to the cluster before connecting. PostgreSQL only; ignored for SQLite.
SERVERPOD_REDIS_HOSTredis.host-The host address of the Redis server
SERVERPOD_REDIS_PORTredis.port-The port number for the Redis server
SERVERPOD_REDIS_USERredis.user-The user name for Redis authentication
SERVERPOD_REDIS_ENABLEDredis.enabledtrueIndicates if Redis is enabled. Defaults to true when a redis section is present; Redis is off when the section is absent or enabled is false.
SERVERPOD_REDIS_REQUIRE_SSLredis.requireSslfalseIndicates if SSL is required for the Redis connection
SERVERPOD_MAX_REQUEST_SIZEmaxRequestSize524288The maximum size of API requests in bytes. Also caps file uploads that post to the API server.
SERVERPOD_VALIDATE_HEADERSvalidateHeaderstrueValidate HTTP headers using the typed API. Set to false to accept headers without the required formatting, for example an unwrapped token in the Authorization header.
SERVERPOD_ALLOWED_ORIGINSallowedOrigins-Browser origins allowed to make credentialed cross-origin calls, as scheme://host[:port]. A YAML list, or comma-separated in the environment variable. Required when authCookie is set. When set, browser WebSocket connections for streaming from other origins are also rejected, with or without authCookie. See Web authentication.
SERVERPOD_AUTH_COOKIE_NAMEauthCookie.name-Name of the auth cookie. Defaults to serverpod_auth. Setting any authCookie field enables cookie auth for web clients; an empty authCookie section is read as unset.
SERVERPOD_AUTH_COOKIE_REFRESH_NAMEauthCookie.refreshName-Name of the JWT refresh cookie. Defaults to <name>_refresh.
SERVERPOD_AUTH_COOKIE_DOMAINauthCookie.domain-Cookie Domain attribute. Defaults to host-only; set to share the cookie across subdomains.
SERVERPOD_AUTH_COOKIE_PATHauthCookie.path/Cookie Path attribute.
SERVERPOD_AUTH_COOKIE_SECUREauthCookie.securetrueWhether the cookie is only sent over https. Set to false only for http://localhost development.
SERVERPOD_AUTH_COOKIE_SAME_SITEauthCookie.sameSitelaxCookie SameSite attribute. Valid options are lax, strict, and none (none requires secure).
SERVERPOD_SESSION_PERSISTENT_LOG_ENABLEDsessionLogs.persistentEnabled-Enables or disables logging session data to the database. Defaults to true if a database is configured, otherwise false.
SERVERPOD_SESSION_LOG_CLEANUP_INTERVALsessionLogs.cleanupInterval-How often to run the log cleanup job. Duration string, for example 24h or 2d. Set to null to disable automated purging. Defaults to 24h only when sessionLogs is not configured at all. See Purge old records.
SERVERPOD_SESSION_LOG_RETENTION_PERIODsessionLogs.retentionPeriod-How long to keep session log entries. Duration string, for example 30d or 60d. Set to null to disable time-based cleanup. Defaults to 90d only when sessionLogs is not configured at all. See Purge old records.
SERVERPOD_SESSION_LOG_RETENTION_COUNTsessionLogs.retentionCount-Maximum number of session log entries to keep. Set to null to disable count-based cleanup. Defaults to 100000 only when sessionLogs is not configured at all. See Purge old records.
SERVERPOD_SESSION_CONSOLE_LOG_ENABLEDsessionLogs.consoleEnabled-Enables or disables logging session data to the console. Defaults to true if no database is configured or the run mode is development, otherwise false.
SERVERPOD_SESSION_CONSOLE_LOG_FORMATsessionLogs.consoleLogFormat-The format for console logging of session data. Valid options are text and json. Defaults to text for run mode development, otherwise json.
SERVERPOD_FUTURE_CALL_EXECUTION_ENABLEDfutureCallExecutionEnabledtrueEnables or disables the execution of future calls.
SERVERPOD_FUTURE_CALL_CONCURRENCY_LIMITfutureCall.concurrencyLimit1The maximum number of concurrent future calls allowed. If the value is negative or null, no limit is applied.
SERVERPOD_FUTURE_CALL_SCAN_INTERVALfutureCall.scanInterval5000The interval in milliseconds for scanning future calls
SERVERPOD_FUTURE_CALL_CHECK_BROKEN_CALLSfutureCall.checkBrokenCalls-Enables or disables the automatic check for broken future calls on startup. By default, the server performs an automatic check if there are less than 1000 calls in the database.
SERVERPOD_FUTURE_CALL_DELETE_BROKEN_CALLSfutureCall.deleteBrokenCallsfalseEnables or disables the deletion of broken future calls when running the check on startup.
SERVERPOD_WEBSOCKET_PING_INTERVALwebsocketPingInterval30The interval in seconds between WebSocket ping messages sent to keep streaming connections alive. Must be a positive integer.

Dart-only options

These options have no environment variable or config-file key. Set them on the ServerpodConfig Dart object passed to the Serverpod constructor.

ServerpodConfig fieldDefaultDescription
healthCheckInterval1mHow often the server collects health metrics. Set to zero to disable health checks.
experimentalDiagnosticHandlerTimeout30sThe timeout for diagnostic event handlers.

Password environment variables

Secrets are read from config/passwords.yaml and can be overridden per secret through environment variables; see Manage secrets. Two forms exist, and when both are set for the same secret, the SERVERPOD_PASSWORD_* form wins:

Environment variableOverrides passwords-file key
SERVERPOD_PASSWORD_<name>Any secret; the prefix is stripped (SERVERPOD_PASSWORD_databasedatabase).
SERVERPOD_DATABASE_PASSWORDdatabase
SERVERPOD_SERVICE_SECRETserviceSecret
SERVERPOD_REDIS_PASSWORDredis

Code generation

Options for config/generator.yaml, which configures serverpod generate.

OptionTypeDefaultDescription
typestringserverThe package type. Valid options are server, module, or internal.
nicknamestring-For modules only. Defines how the module is referenced in code.
client_package_pathstring../[name]_clientPath to the client package relative to the server.
server_test_tools_pathstringtest/integration/test_toolsPath where test tools are generated. Remove this to disable test tools generation.
shared_packageslist-Paths to shared packages containing models usable by both server and client.
modulesmap-Module dependencies with optional nicknames.
extraClasseslist-List of custom serializable classes to include in code generation.
serialize_as_jsonb_by_defaultboolfalseWhen true, all serializable fields default to jsonb storage instead of json.
featuresmap{database: true}Feature flags. Currently only database is supported.
experimental_featuresmap-Experimental features. Available keys: databaseSync (enables database: sync) and all.
  • Configuration: how the three configuration sources work, run modes, secrets, and package types.
  • Redis: enabling Redis, the password, and connecting a GUI.
  • Running your server: the run mode and files the server loads on start.