SurrealDB Docs Logo

Enter a search query

Environment variables

Environment variables can be used to tailor the behaviour of a running SurrealDB instance.

SurrealDB environment variables

Environment variableDefault valueNotes
SURREAL_BUCKET_FOLDER_ALLOWLISTemptySpecifies a list of paths in which files can be accessed.
SURREAL_BUILD_METADATAfalseThe version identifier of this build. Defaults to the CARGO_PKG_VERSION environment variable if not specified.
SURREAL_COUNT_BATCH_SIZE10,000

Available since: v2.2.0

The maximum number of keys that should be scanned at once for count queries.
SURREAL_DATASTORE_CACHE_SIZE1,000

Available since: v2.1.0

The number of definitions which can be cached across transactions.
SURREAL_EXPERIMENTAL_BEARER_ACCESSfalseEnable experimental bearer access and stateful access grant management. Still under active development. Using this experimental feature may introduce risks related to breaking changes and security issues.
SURREAL_EXPERIMENTAL_GRAPHQLfalseEnables experimental graphql integration. Still under active development. Using this experimental feature may introduce risks related to breaking changes and security issues.
SURREAL_EXPORT_BATCH_SIZE1000The maximum number of keys that should be scanned at once for export queries.
SURREAL_EXTERNAL_SORTING_BUFFER_LIMIT50000Specifies the buffer limit for external sorting.
SURREAL_FILE_ALLOWLIST20

Available since: v2.1.5

Limits file access for the mapper filter to only the specified allowed file paths. The paths must be provided as absolute paths, separated by a colon (:) on Unix-like systems or a semicolon (;) on Windows.
SURREAL_FUNCTION_ALLOCATION_LIMIT20Used to limit allocation for builtin functions.
SURREAL_GLOBAL_BUCKETNoneSpecifies the name of a global bucket for file data.
SURREAL_GENERATION_ALLOCATION_LIMIT20Limits memory allocation for certain built-in functions (e.g., string::replace) to avoid uncontrolled memory usage. default is 1,048,576 bytes (computed as 2^20).
SURREAL_GLOBAL_BUCKET_ENFORCEDfalseWhether to enforce a global bucket for file data.
SURREAL_HTTP_MAX_API_BODY_SIZE1 MiBThe maximum HTTP body size of the HTTP /api endpoint.
SURREAL_HTTP_MAX_IMPORT_BODY_SIZE4398046511104 (4 GiB)Maximum HTTP body size of the HTTP /import endpoints
SURREAL_HTTP_MAX_KEY_BODY_SIZE16384 (16 KiB)Maximum HTTP body size of the HTTP /key endpoints
SURREAL_HTTP_MAX_ML_BODY_SIZE4398046511104 (4 GiB)Maximum HTTP body size of the HTTP /ml endpoints
SURREAL_HTTP_MAX_RPC_BODY_SIZE4194304 (4 MiB)Maximum HTTP body size of the HTTP /rpc endpoint.
SURREAL_HTTP_MAX_SQL_BODY_SIZE1048576 (1 MiB)Maximum HTTP body size of the HTTP /sql endpoint
SURREAL_HTTP_MAX_SIGNIN_BODY_SIZE1024 (1 KiB)The maximum HTTP body size of the HTTP /signin endpoints
SURREAL_HTTP_MAX_SIGNUP_BODY_SIZE1024 (1 KiB)Maximum HTTP body size of the HTTP /signup endpoint.
SURREAL_IDIOM_RECURSION_LIMIT256The maximum recursive idiom path depth allowed.
SURREAL_IMPORT_FILENonePath to a SurrealQL file that will be imported when starting the server.
SURREAL_INDEXING_BATCH_SIZE250The maximum number of keys to scan at once per concurrent indexing batch.
SURREAL_INSECURE_FORWARD_ACCESS_ERRORSfalseForward all signup/signin/authenticate query errors to a client performing authentication. Do not use in production.
SURREAL_MAX_COMPUTATION_DEPTH120/// Specifies how deep recursive computation will go before erroring.
SURREAL_MAX_CONCURRENT_TASKS64Specifies how many concurrent jobs can be buffered in the worker channel.
SURREAL_MAX_HTTP_REDIRECTS10

Available since: v2.0.5

The maximum number of HTTP redirects allowed within http functions.
SURREAL_MAX_OBJECT_PARSING_DEPTH10Specifies how deep the parser will parse nested objects and arrays in a query.
SURREAL_MAX_ORDER_LIMIT_PRIORITY_QUEUE_SIZE1000

Available since: v2.2.0

The maximum size of the priority queue triggering usage of the priority queue for the result collector.
SURREAL_MAX_QUERY_PARSING_DEPTH20Specifies how deep the parser will parse recursive queries (queries within queries).
SURREAL_MAX_STREAM_BATCH_SIZE1000The maximum number of keys that should be fetched when streaming range scans in a Scanner.
SURREAL_MEMORY_THRESHOLD

Available since: v2.1.5

Configuring the memory threshold which can be used across the programme to check if the amount of memory available to the programme is lower than required. The value can be specified as bytes (b, or without any suffix), kibibytes (k, kb, or kib), mebibytes (m, mb, or mib), or gibibytes (g, gb, or gib). If the environment variable is not specified, then the threshold is not used, and no memory limit is enabled.
SURREAL_NET_MAX_CONCURRENT_REQUESTS1,048,576 concurrent requestsAdds a global limit for concurrent server requests, and introduces a new environment variable
SURREAL_NORMAL_FETCH_SIZE500The maximum number of keys that should be scanned at once in general queries.
SURREAL_REGEX_CACHE_SIZE100The number of computed regexes which can be cached in the engine.
SURREAL_REGEX_SIZE_LIMIT10,485,760

Available since: v2.1.5

Limits the maximum allowed size (in bytes) for compiled regular expressions. This prevents excessive memory consumption when building complex or very large regex patterns.
SURREAL_RUNTIME_MAX_BLOCKING_THREADS512Number of threads which can be started for blocking operations.
SURREAL_RUNTIME_STACK_SIZE10485760 (10 MiB)Runtime thread memory stack size. Stack size is doubled if compiled from source in Debug mode.
SURREAL_RUNTIME_WORKER_THREADSNumber of CPU cores (minimum 4)Number of runtime worker threads used to start.
SURREAL_SCRIPTING_MAX_MEMORY_LIMIT2097152 (2 MiB)Maximum memory limit of the JavaScript function runtime.
SURREAL_SCRIPTING_MAX_STACK_SIZE262144 (256 KiB)Maximum stack size of the JavaScript function runtime.
SURREAL_SCRIPTING_MAX_TIME_LIMIT5000 (5000 milliseconds or 5 seconds)

Available since: v2.0.5

Maximum allowed time that a JavaScript function is allowed to run for.
SURREAL_SURREALCS_CONNECTION_POOL_SIZENumber of CPUs on the current device

Available since: v2.0.2

Size of the SurrealCS connection pool.
SURREAL_TELEMETRY_DISABLE_METRICSfalse

Available since: v2.1.3

Disables sending metrics to the GRPC OTEL collector.
SURREAL_TELEMETRY_DISABLE_TRACINGfalse

Available since: v2.1.3

Disables sending traces to the GRPC OTEL collector.
SURREAL_TELEMETRY_NAMESPACENoneIf set then use this as value for the namespace label when sending telemetry
SURREAL_TELEMETRY_PROVIDERNoneIf set to “otlp” then telemetry is sent to the GRPC OTEL collector.
SURREAL_TEMPORARY_DIRECTORYNoneSets the directory for storing temporary database files.
SURREAL_TRANSACTION_CACHE_SIZE10000Specifies the number of items which can be cached within a single transaction.
SURREAL_WEBSOCKET_MAX_CONCURRENT_REQUESTS4 times the number of CPU cores, minimum 12Maximum concurrent tasks that can be handled on each WebSocket.
SURREAL_WEBSOCKET_MAX_FRAME_SIZE16777216 (16 MiB)Maximum WebSocket frame size.
SURREAL_WEBSOCKET_MAX_MESSAGE_SIZE134217728 (128 MiB)Maximum WebSocket message size.
SURREAL_WEBSOCKET_RESPONSE_BUFFER_SIZE0How many responses can be buffered when delivering to the client.
SURREAL_WEBSOCKET_RESPONSE_CHANNEL_SIZE100Configuring the WebSocket buffer size and the WebSocket response queue size.
SURREAL_WEBSOCKET_RESPONSE_FLUSH_PERIOD3How often (in milliseconds) any buffered responses are flushed to the WebSocket client.
Environment variableFor command(s)Command argDetails
SURREAL_AUTH_LEVELsurreal export, import, sqlauth-levelAuthentication level to use when connecting.
SURREAL_BINDsurreal startbindThe hostname or IP address(es) to listen for connections on.
SURREAL_CAPS_ALLOW_ALLsurreal startallow-allAllow all capabilities.
SURREAL_CAPS_ALLOW_ARBITRARY_QUERYsurreal startallow-arbitrary-queryAllows arbitrary queries to be used by user groups. Possible user groups are: ‘guest’, ‘record’, and ‘system’.
SURREAL_CAPS_ALLOW_EXPERIMENTALsurreal startallow-experimentalAllow execution of experimental features.
SURREAL_CAPS_ALLOW_FUNCsurreal startallow-funcsAllow execution of all or certain functions.
SURREAL_CAPS_ALLOW_GUESTSsurreal startallow-guestsAllow guest users to execute queries.
SURREAL_CAPS_ALLOW_NETsurreal startallow-netAllow all or certain outbound network access.
SURREAL_CAPS_ALLOW_SCRIPTsurreal startallow-scriptingAllow execution of embedded scripting functions.
SURREAL_CAPS_DENY_ALLsurreal startdeny-allDeny all capabilities.
SURREAL_CAPS_DENY_FUNCsurreal startdeny-funcsDeny execution of all or certain functions.
SURREAL_CAPS_DENY_GUESTSsurreal startdeny-guestsDeny guest users to execute queries.
SURREAL_CAPS_DENY_NETsurreal startdeny-netDeny all or certain outbound access paths.
SURREAL_CAPS_DENY_SCRIPTsurreal startdeny-scriptingDeny execution of embedded scripting functions.
SURREAL_CLIENT_IPsurreal startclient-ipThe method of detecting the client’s IP address.
SURREAL_DATABASEsurreal export, import, sqldatabaseThe database selected for the operation.
SURREAL_HIDE_WELCOMEsurreal sqlhide-welcomeWhether to show welcome message.
SURREAL_KEYsurreal startkeyEncryption key to use for on-disk encryption.
SURREAL_KVS_CAsurreal startkvs-caPath to the CA file used when connecting to the remote KV store.
SURREAL_KVS_CERTsurreal startkvs-certPath to the certificate file used when connecting to the remote KV store.
SURREAL_KVS_KEYsurreal startkvs-keyPath to the private key file used when connecting to the remote KV store.
SURREAL_LOGsurreal fix, startlogThe logging level for the database server.
SURREAL_NAMEsurreal ml exportnameThe name of the model.
SURREAL_NAMESPACEsurreal export, import, sqlnamespaceThe namespace selected for the operation.
SURREAL_NO_BANNERsurreal startno-bannerWhether to hide the startup banner.
SURREAL_NO_IDENTIFICATION_HEADERSsurreal startno-identification-headersWhether to suppress the server name and version headers.
SURREAL_PASSsurreal export, import, sql, startpassword, passDatabase authentication password to use when connecting.
SURREAL_PATHsurreal fix, startpathDatabase path used for storing data.
SURREAL_QUERY_TIMEOUTsurreal startquery-timeoutThe maximum duration that a set of statements can run for.
SURREAL_STRICTstartstrictWhether strict mode is enabled on this database instance.
SURREAL_TEMPORARY_DIRECTORYsurreal starttemporary-directorySets the directory for storing temporary database files
SURREAL_TICK_INTERVALsurreal starttick-intervalThe interval at which to run node agent tick (including garbage collection).
SURREAL_TOKENsurreal export, import, sqltokenAuthentication token in JWT format to use when connecting.
SURREAL_TRANSACTION_TIMEOUTsurreal starttransaction-timeoutThe maximum duration that any single transaction can run for.
SURREAL_UNAUTHENTICATEDsurreal startunauthenticatedWhether to allow unauthenticated access.
SURREAL_USERsurreal export, import, sql, startusername, userDatabase authentication username to use when connecting.
SURREAL_VERSIONsurreal ml exportnameThe version of the model.
SURREAL_WEB_CRTsurreal startweb-crtPath to the certificate file for encrypted client connections.
SURREAL_WEB_KEYsurreal startweb-keyPath to the private key file for encrypted client connections.

Environment variables by storage backend

These environment variables are used to configure the storage backend for SurrealDB.

FoundationDB environment variables

Environment variableDefault valueNotes
SURREAL_FOUNDATIONDB_TRANSACTION_MAX_RETRY_DELAY500The maximum delay between transaction retries in milliseconds.
SURREAL_FOUNDATIONDB_TRANSACTION_RETRY_LIMIT5The maximum number of times a transaction can be retried.
SURREAL_FOUNDATIONDB_TRANSACTION_TIMEOUT5000The maximum transaction timeout in milliseconds.

RocksDB environment variables

Environment variableDefault valueNotes
SURREAL_ROCKSDB_BACKGROUND_FLUSHfalseWhether to enable background WAL file flushing.
SURREAL_ROCKSDB_BACKGROUND_FLUSH_INTERVAL200The interval in milliseconds between background flushes.
SURREAL_ROCKSDB_BLOCK_CACHE_SIZEWhichever is larger of “System total memory / 2 - 1GiB” and “512MiB”RocksDB block cache size in bytes
SURREAL_ROCKSDB_BLOCK_SIZE64 KiBThe size of each uncompressed data block in bytes.
SURREAL_ROCKSDB_COMPACTION_READAHEAD_SIZE16 MiBThe readahead buffer size used during compaction.
SURREAL_ROCKSDB_COMPACTION_STYLE”level”

Available since: v2.0.3

Use to specify the database compaction style.
SURREAL_ROCKSDB_DELETION_FACTORY_DELETION_COUNT50

Available since: v2.0.3

The number of deletions to track in the window.
SURREAL_ROCKSDB_DELETION_FACTORY_RATIO0.5

Available since: v2.0.3

The ratio of deletions to track in the window.
SURREAL_ROCKSDB_DELETION_FACTORY_WINDOW_SIZE1000

Available since: v2.0.3

The size of the window used to track deletions.
SURREAL_ROCKSDB_ENABLE_BLOB_FILEStrueWhether to enable separate key and value file storage.
SURREAL_ROCKSDB_ENABLE_MEMORY_MAPPED_READSfalseWhether to enable memory-mapped reads.
SURREAL_ROCKSDB_ENABLE_MEMORY_MAPPED_WRITESfalseWhether to enable memory-mapped writes.
SURREAL_ROCKSDB_ENABLE_PIPELINED_WRITEStrueWhether to use separate queues for WAL writes and memtable writes.
SURREAL_ROCKSDB_FILE_COMPACTION_TRIGGER16The number of files needed to trigger level 0 compaction.
SURREAL_ROCKSDB_JOBS_COUNTNumber of CPUs * 2

Available since: v2.0.3

The maximum number of threads to use for flushing and compaction.
SURREAL_ROCKSDB_KEEP_LOG_FILE_NUM20The maximum number of information log files to keep.
SURREAL_ROCKSDB_MAX_CONCURRENT_SUBCOMPACTIONS4The maximum number threads which will perform compactions.
SURREAL_ROCKSDB_MAX_OPEN_FILES1024The maximum number of open files which can be opened by RocksDB.
SURREAL_ROCKSDB_MAX_WRITE_BUFFER_NUMBER32The maximum number of write buffers which can be used.
SURREAL_ROCKSDB_MIN_BLOB_SIZE4096The minimum size of a value for it to be stored in blob files.
SURREAL_ROCKSDB_MIN_WRITE_BUFFER_NUMBER_TO_MERGE6The minimum number of write buffers to merge before writing to disk.
SURREAL_ROCKSDB_STORAGE_LOG_LEVEL”warn”The information log level of the RocksDB library.
SURREAL_ROCKSDB_TARGET_FILE_SIZE_BASE128 MiBThe target file size for compaction in bytes.
SURREAL_ROCKSDB_TARGET_FILE_SIZE_MULTIPLIER10The target file size multiplier for each compaction level.
SURREAL_ROCKSDB_THREAD_COUNTNumber of CPUs on machineThe number of threads to start for flushing and compaction.
SURREAL_ROCKSDB_WAL_SIZE_LIMIT1024 MB (1 GB)The write-ahead-log size limit in MiB.
SURREAL_ROCKSDB_WRITE_BUFFER_SIZE268435456 (256 MiB)The amount of data each write buffer can build up in memory.
SURREAL_SYNC_DATAfalseControls the behaviour of RocksDB and SurrealKV. Allows data durability configuration, ensuring that the database can be configured for writes to be synced to disk before transactions are confirmed to be completed.

SurrealKV environment variables

Environment variableDefault valueNotes
SURREAL_SURREALKV_MAX_SEGMENT_SIZE512 MiBThe maximum size of a single data file segment.
SURREAL_SURREALKV_MAX_VALUE_CACHE_SIZEWhichever is larger of “System total memory / 2 - 1GiB” and “512MiB”The size of the in-memory value cache for SurrealKV.
SURREAL_SURREALKV_MAX_VALUE_THRESHOLD64The size in bytes to store values in the tree, or a separate log file.
SURREAL_SYNC_DATAfalseControls the behaviour of RocksDB and SurrealKV. Allows data durability configuration, ensuring that the database can be configured for writes to be synced to disk before transactions are confirmed to be completed.

TiKV environment variables

Environment variableDefault valueNotes
SURREAL_TIKV_API_VERSION1Which TiKV cluster API version to use.
SURREAL_TIKV_ASYNC_COMMITtrueWhether to use asynchronous transactions.
SURREAL_TIKV_KEYSPACENoneA string specifying the keyspace identifier for data isolation.
SURREAL_TIKV_ONE_PHASE_COMMITtrueWhether to use one-phase transaction commit.
SURREAL_TIKV_REQUEST_TIMEOUT10The duration in seconds for requests before they time out.

Command environment variables

Many of the arguments passed into the CLI can be set using the above environment variables instead.

As each of these environment variables correspond to a flag passed into a command, it is good practice to put together a command that matches the environment variables you wish to set. Once the database server conforms to your expected behaviour, you can then pull out the values passed into each flag for your environment variables.

For example, take the following command to start the database.

surreal start --user root --pass root --allow-net --deny-funcs "crypto::md5, http::post, http::delete"

If we now wanted to use environment variables instead of the --allow-net and --deny-funcs flags, we would use the SURREAL_CAPS_ALLOW_NET and SURREAL_CAPS_DENY_FUNC environment variables.

As the --allow-net flag was passed in without a following value, the same will be the case with the SURREAL_CAPS_ALLOW_NET environment variable, becoming SURREAL_CAPS_ALLOW_NET=. The --deny-funcs flag can also be used on its own to deny execution of all functions, but in this case is followed by a string to indicate which exact functions are not allowed to be executed. As such, the SURREAL_CAPS_DENY_FUNC environment variable must also be followed by a string, becoming SURREAL_CAPS_DENY_FUNC="crypto::md5, http::post, http::delete".

The command would then look like the following:

SURREAL_CAPS_ALLOW_NET SURREAL_CAPS_DENY_FUNC="crypto::md5, http::post, http::delete" surreal start --user root --pass root

Surreal Cloud environment variables

Instances on Surreal Cloud are not started with a CLI command or environment variables. Instead, they can be set on the Configure Instance panel.