Go to your terminal session and run this command to set the API URL to point to a self-hosted Prefect server instance:
prefect config set PREFECT_API_URL="http://127.0.0.1:4200/api"
You can save the API server address in a Prefect profile.
Whenever that profile is active, the API endpoint is at that address.
See Profiles and configuration for more information on profiles and configurable Prefect settings.
# Upgrade to the latest versionprefect server database upgrade -y# Downgrade to the previous versionprefect server database downgrade -y -r -1# Downgrade to a specific revisionprefect server database downgrade -y -r d20618ce678e
On PostgreSQL, migrations use a dedicated statement timeout instead of the general database timeout, and have no timeout by default. For large databases where you want to bound how long a migration can run, set a migration timeout:
export PREFECT_SERVER_DATABASE_MIGRATION_TIMEOUT=600prefect server database upgrade -y
Multi-worker mode has specific infrastructure requirements:
PostgreSQL database — SQLite is not supported due to database locking issues
Redis for messaging, event ordering, and concurrency lease storage — the in-memory defaults do not work across processes
prefect server start --workers validates these requirements at startup. If any required
Redis-backed setting is still using its in-memory default, the server exits with an error
before starting. See the configuration example below for the full set of required settings.
# Set PostgreSQL connectionprefect config set PREFECT_SERVER_DATABASE_CONNECTION_URL="postgresql+asyncpg://postgres:password@localhost:5432/prefect"# Configure Redis-backed messaging, event ordering, and lease storageprefect config set PREFECT_SERVER_EVENTS_MESSAGING_BROKER="prefect_redis.messaging"prefect config set PREFECT_SERVER_EVENTS_MESSAGING_CACHE="prefect_redis.messaging"prefect config set PREFECT_SERVER_EVENTS_CAUSAL_ORDERING="prefect_redis.ordering"prefect config set PREFECT_SERVER_CONCURRENCY_LEASE_STORAGE="prefect_redis.lease_storage"# Configure Redis connectionexport PREFECT_REDIS_MESSAGING_HOST="redis"export PREFECT_REDIS_MESSAGING_PORT="6379"export PREFECT_REDIS_MESSAGING_DB="0"# Start server with 4 workersprefect server start --workers 4
For a complete Redis setup including authentication, TLS, and Docket coordination for
background services, see How to scale self-hosted Prefect.
The number of workers should typically match the number of CPU cores available to your server process, but you may need to experiment to find the optimal value for your workload.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Prefect","colors":{"primary":"#2D6DF6","light":"#5F92FF","dark":"#2D6DF6"},"logo":{"light":"https://mintcdn.com/prefect-bd373955/2_4m_dDmEdgqK7r9/logos/logo-wordmark-dark.svg?fit=max\u0026auto=format\u0026n=2_4m_dDmEdgqK7r9\u0026q=85\u0026s=076c95a93dbe29192ba9129faefcc878","dark":"https://mintcdn.com/prefect-bd373955/2_4m_dDmEdgqK7r9/logos/logo-wordmark-light.svg?fit=max\u0026auto=format\u0026n=2_4m_dDmEdgqK7r9\u0026q=85\u0026s=46ef25a1069c303ca7d9e24ec801e760","href":"https://www.prefect.io/docs"},"favicon":"https://mintcdn.com/prefect-bd373955/2_4m_dDmEdgqK7r9/logos/favicon.svg?fit=max\u0026auto=format\u0026n=2_4m_dDmEdgqK7r9\u0026q=85\u0026s=c0e62122cb72036e569b2656916a1b33","api":{"playground":{"display":"simple"}},"appearance":{"default":"light","strict":false},"navbar":{"primary":{"type":"github","href":"https://github.com/PrefectHQ/Prefect"}},"footer":{"socials":{"bluesky":"https://bsky.app/profile/prefect.io","github":"https://github.com/PrefectHQ/prefect","linkedin":"https://www.linkedin.com/company/prefect/mycompany","slack":"https://prefect.io/slack","x":"https://x.com/PrefectIO","youtube":"https://www.youtube.com/c/PrefectIO"}},"seo":{"metatags":{"canonical":"https://www.prefect.io/docs"}},"integrations":{"ga4":{"measurementId":"G-8GR5P04T5Y"},"gtm":{"tagId":"GTM-N633BZ8"}},"errors":{"404":{"redirect":false}},"contextual":{"options":["copy","view"],"display":"header"},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"prefect-bd373955","hasAudioNarration":false,"actualSubdomain":"prefect-bd373955","customDomains":[],"gitSource":{"type":"github","owner":"prefecthq","repo":"prefect","deployBranch":"main","contentDirectory":"docs","isPrivate":false,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6aebae2be8d23663794098e8","collectionId":"28a32e15-27de-4edf-91c2-0682e8bb6873","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6aebae2be8d23663794098e8"},"feedback":{"thumbs":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"REMOVE_BRANDING":{"status":"ENABLED"},"CONTEXTUAL_FEEDBACK":{"status":"ENABLED"},"CODE_SNIPPET_FEEDBACK":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6aee42ba68213475f1385309","clientVersion":"0.0.4076","searchFilterCounts":[{"language":"default","tag":"API Reference","count":1172},{"language":"default","tag":"Python SDK Reference","count":364},{"language":"default","tag":"Integrations","count":329},{"language":"default","tag":"REST API","count":183},{"language":"default","tag":"Server API","count":181},{"language":"default","tag":"prefect.server","count":148},{"language":"default","tag":"SDK Reference","count":127},{"language":"default","tag":"How-to Guides","count":71},{"language":"default","tag":"models","count":60},{"language":"default","tag":"api","count":39}]},"assistantConfig":{},"basePath":"/docs","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"comment-mode","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"styles.css","content":"#topbar-cta-button>a>span{background-color:#2d6df6;border-radius:0.25rem}#topbar-cta-button>a{padding:0.5rem 1rem}#topbar-cta-button>a div>span{font-weight:400;letter-spacing:0.4px}#topbar-cta-button>a div>span,#topbar-cta-button>a div>svg{color:#fff}img{filter:none!important}@import url(\"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700\u0026display=swap\");@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700\u0026display=swap\");body{font-family:\"Inter\", sans-serif}h1,h2,h3,h4,h5,h6{font-family:\"Roboto\", sans-serif}p{font-family:\"Inter\", sans-serif}[role=\"listitem\"] *:last-child:not(.code-block,.link){border-bottom:none!important}.badge{display:table;margin:0 0 1rem;font-family:\"Inter\", sans-serif;font-size:0.6875rem;font-weight:600;line-height:1;letter-spacing:0.02em;text-transform:uppercase;padding:0.35em 0.6em;border-radius:0.375rem;white-space:nowrap}.badge.cloud{color:#fff;background-color:#2d6df6}.badge.cloud::after{content:\"Prefect Cloud\"}"},{"filePath":"assets/code.css","content":".namespace{opacity:0.7}.token.doctype .token.doctype-tag{color:#79c0ff}.token.doctype .token.name{color:#d2a8ff}.token.comment,.token.prolog{color:#8b949e}.token.punctuation,.language-html .language-css .token.punctuation,.language-html .language-javascript .token.punctuation{color:#c9d1d9}.token.property,.token.tag,.token.boolean,.token.number,.token.constant,.token.symbol,.token.inserted,.token.unit{color:#79c0ff}.token.selector,.token.attr-name,.token.string,.token.char,.token.builtin,.token.deleted{color:#79c0ff}.token.plain-text{color:#fafafa}.language-css .token.string.url{text-decoration:underline}.token.operator,.token.entity{color:#79c0ff}.token.operator.arrow{color:#ff7b72}.token.atrule{color:#79c0ff}.token.atrule .token.rule{color:#d2a8ff}.token.atrule .token.url{color:#79c0ff}.token.atrule .token.url .token.function{color:#79c0ff}.token.atrule .token.url .token.punctuation{color:#d4d4d4}.token.keyword{color:#ff7b72}.token.keyword.module,.token.keyword.control-flow{color:#c586c0}.token.function,.token.function .token.maybe-class-name{color:#d2a8ff}.token.regex{color:#a5d6ff}.token.important{color:#ff7b72}.token.italic{font-style:italic;color:#c9d1d9}.token.constant{color:#79c0ff}.token.class-name,.token.maybe-class-name{color:#d2a8ff}.token.console{color:#9cdcfe}.token.parameter{color:#79c0ff}.token.interpolation{color:#79c0ff}.token.punctuation.interpolation-punctuation{color:#569cd6}.token.boolean{color:#ff7b72}.token.property,.token.variable,.token.imports .token.maybe-class-name,.token.exports .token.maybe-class-name{color:#79c0ff}.token.selector{color:#7ee787}.token.escape{color:#7ee787}.token.tag{color:#7ee787}.token.tag .token.punctuation{color:#808080}.token.cdata{color:#808080}.token.attr-name{color:#79c0ff}.token.attr-value,.token.attr-value .token.punctuation{color:#a5d6ff}.token.attr-value .token.punctuation.attr-equals{color:#d4d4d4}.token.entity{color:#79c0ff}.token.namespace{color:#7ee787}.token.operator{color:#94a3b8}pre[class*=\"language-javascript\"],code[class*=\"language-javascript\"],pre[class*=\"language-jsx\"],code[class*=\"language-jsx\"],pre[class*=\"language-typescript\"],code[class*=\"language-typescript\"],pre[class*=\"language-tsx\"],code[class*=\"language-tsx\"]{color:#79c0ff}pre[class*=\"language-css\"],code[class*=\"language-css\"]{color:#a5d6ff}pre[class*=\"language-html\"],code[class*=\"language-html\"]{color:#c9d1d9}.language-regex .token.anchor{color:#dcdcaa}.language-html .token.punctuation{color:#808080}span.language-json .token.punctuation{color:#4b5563}:is(.dark span.language-json .token.punctuation){color:#d1d5db}span.language-json .token.property{color:#0284c7}:is(.dark span.language-json .token.property){color:9cdcfe}span.language-json .token.string{color:#d97706}:is(.dark span.language-json .token.string){color:#ce9178}span.language-json .token.number{color:#16a34a}:is(.dark span.language-json .token.number){color:#b5cea8}.line-highlight.line-highlight{background:#f7ebc6;box-shadow:inset 5px 0 0 #f7d87c;z-index:0}"}],"page":{"pagePath":"v3/how-to-guides/self-hosted/server-cli","slug":"/v3/how-to-guides/self-hosted/server-cli","pageMetadata":{"title":"How to run a local Prefect server","sidebarTitle":"Run a local Prefect server","description":"Get started with self-hosting by running Prefect server locally.","keywords":["self-hosted","server","CLI","local","prefect server start"],"href":"/v3/how-to-guides/self-hosted/server-cli"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Get started with self-hosting by running Prefect server locally.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Note,OptimizedImage,Tip}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Tip)_missingMdxReference(`Tip`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`The `,_jsx(_components.a,{href:`/v3/get-started/install`,children:`Prefect CLI`}),` is the easiest way to start a local instance of Prefect server.`]}),`\n`,_jsx(Heading,{level:`2`,id:`start-the-server`,children:`Start the server`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Spin up a self-hosted Prefect server instance UI with the `,_jsx(_components.code,{children:`prefect server start`}),` CLI command in the terminal:`]}),`\n`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` server`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` start`})]}),`\n`]})})}),`\n`,_jsxs(_components.ol,{start:`2`,children:[`\n`,_jsxs(_components.li,{children:[`Open the URL for the Prefect server UI (`,_jsx(_components.a,{href:`http://127.0.0.1:4200`,children:`http://127.0.0.1:4200`}),` by default) in a browser.`]}),`\n`]}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/prefect-bd373955/rnvMFOjSDxgHq1Ac/v3/img/ui/self-hosted-server-dashboard.png?fit=max\u0026auto=format\u0026n=rnvMFOjSDxgHq1Ac\u0026q=85\u0026s=ea52a0ecc2a49f43521794fa1434676c`,alt:`Viewing the dashboard in the Prefect UI.`,\"data-og-width\":`1600`,width:`1600`,\"data-og-height\":`1122`,height:`1122`,\"data-path\":`v3/img/ui/self-hosted-server-dashboard.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/prefect-bd373955/rnvMFOjSDxgHq1Ac/v3/img/ui/self-hosted-server-dashboard.png?w=280\u0026fit=max\u0026auto=format\u0026n=rnvMFOjSDxgHq1Ac\u0026q=85\u0026s=7d9675041380a8a709a481a66a35f58e 280w, https://mintcdn.com/prefect-bd373955/rnvMFOjSDxgHq1Ac/v3/img/ui/self-hosted-server-dashboard.png?w=560\u0026fit=max\u0026auto=format\u0026n=rnvMFOjSDxgHq1Ac\u0026q=85\u0026s=29ff0870fd2f73926bda0b7543658c3e 560w, https://mintcdn.com/prefect-bd373955/rnvMFOjSDxgHq1Ac/v3/img/ui/self-hosted-server-dashboard.png?w=840\u0026fit=max\u0026auto=format\u0026n=rnvMFOjSDxgHq1Ac\u0026q=85\u0026s=99894f7e3176160e1ea9845c5bd7cf9b 840w, https://mintcdn.com/prefect-bd373955/rnvMFOjSDxgHq1Ac/v3/img/ui/self-hosted-server-dashboard.png?w=1100\u0026fit=max\u0026auto=format\u0026n=rnvMFOjSDxgHq1Ac\u0026q=85\u0026s=b0814984ad6b5f488ee033bd6580fcb6 1100w, https://mintcdn.com/prefect-bd373955/rnvMFOjSDxgHq1Ac/v3/img/ui/self-hosted-server-dashboard.png?w=1650\u0026fit=max\u0026auto=format\u0026n=rnvMFOjSDxgHq1Ac\u0026q=85\u0026s=8f55cdfdc6b37c35b1e79a7a4540af25 1650w, https://mintcdn.com/prefect-bd373955/rnvMFOjSDxgHq1Ac/v3/img/ui/self-hosted-server-dashboard.png?w=2500\u0026fit=max\u0026auto=format\u0026n=rnvMFOjSDxgHq1Ac\u0026q=85\u0026s=ad4b4179a42f46c9c1a4dbc7136d82aa 2500w`}),`\n`,_jsxs(_components.ol,{start:`3`,children:[`\n`,_jsx(_components.li,{children:`Shut down the Prefect server with ctrl + c in the terminal.`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`configure-the-server`,children:`Configure the server`}),`\n`,_jsx(_components.p,{children:`Go to your terminal session and run this command to set the API URL to point to a self-hosted Prefect server instance:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` config`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` set`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` PREFECT_API_URL=\"http://127.0.0.1:4200/api\"`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`You can save the API server address in a Prefect profile.\nWhenever that profile is active, the API endpoint is at that address.\nSee `,_jsx(_components.a,{href:`/v3/develop/settings-and-profiles/`,children:`Profiles and configuration`}),` for more information on profiles and configurable Prefect settings.`]}),`\n`,_jsx(Heading,{level:`2`,id:`database-configuration`,children:`Database configuration`}),`\n`,_jsx(Heading,{level:`3`,id:`use-sqlite-default`,children:`Use SQLite (default)`}),`\n`,_jsxs(_components.p,{children:[`By default, Prefect uses a SQLite database stored at `,_jsx(_components.code,{children:`~/.prefect/prefect.db`}),`. No additional configuration is needed for basic use.`]}),`\n`,_jsx(Heading,{level:`3`,id:`use-postgresql`,children:`Use PostgreSQL`}),`\n`,_jsx(_components.p,{children:`To use PostgreSQL as your database backend:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsx(_components.li,{children:`Set the database connection URL:`}),`\n`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` config`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` set`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` PREFECT_SERVER_DATABASE_CONNECTION_URL=\"postgresql+asyncpg://postgres:yourTopSecretPassword@localhost:5432/prefect\"`})]}),`\n`]})})}),`\n`,_jsxs(_components.ol,{start:`2`,children:[`\n`,_jsx(_components.li,{children:`Start the server:`}),`\n`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` server`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` start`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`For more database configuration options, see the `,_jsx(_components.a,{href:`/v3/api-ref/settings-ref#database`,children:`database settings reference`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`database-management-commands`,children:`Database management commands`}),`\n`,_jsx(Heading,{level:`3`,id:`reset-the-database`,children:`Reset the database`}),`\n`,_jsx(_components.p,{children:`Clear all data and reapply the schema:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` server`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` database`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` reset`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -y`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`manage-migrations`,children:`Manage migrations`}),`\n`,_jsx(_components.p,{children:`Apply database migrations:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`8`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Upgrade to the latest version`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` server`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` database`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` upgrade`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -y`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Downgrade to the previous version`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` server`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` database`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` downgrade`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -y`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -r`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -1`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Downgrade to a specific revision`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` server`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` database`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` downgrade`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -y`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -r`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` d20618ce678e`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`On PostgreSQL, migrations use a dedicated statement timeout instead of the general database timeout, and have no timeout by default. For large databases where you want to bound how long a migration can run, set a migration timeout:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` PREFECT_SERVER_DATABASE_MIGRATION_TIMEOUT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`600`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` server`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` database`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` upgrade`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -y`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`multi-worker-api-server`,children:`Multi-worker API server`}),`\n`,_jsx(_components.p,{children:`For high-throughput scenarios, you can run the server with multiple worker processes to handle concurrent requests more efficiently:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` server`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` start`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --workers`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 4`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`This starts 4 worker processes to handle API and UI requests concurrently.`}),`\n`,_jsx(Heading,{level:`3`,id:`requirements-for-multi-worker-mode`,children:`Requirements for multi-worker mode`}),`\n`,_jsx(_components.p,{children:`Multi-worker mode has specific infrastructure requirements:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`PostgreSQL database`}),` — SQLite is not supported due to database locking issues`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Redis for messaging, event ordering, and concurrency lease storage`}),` — the in-memory defaults do not work across processes`]}),`\n`]}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`prefect server start --workers`}),` validates these requirements at startup. If any required\nRedis-backed setting is still using its in-memory default, the server exits with an error\nbefore starting. See the configuration example below for the full set of required settings.`]})}),`\n`,_jsx(Heading,{level:`3`,id:`configuration-example`,children:`Configuration example`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`16`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`16`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Set PostgreSQL connection`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` config`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` set`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` PREFECT_SERVER_DATABASE_CONNECTION_URL=\"postgresql+asyncpg://postgres:password@localhost:5432/prefect\"`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Configure Redis-backed messaging, event ordering, and lease storage`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` config`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` set`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` PREFECT_SERVER_EVENTS_MESSAGING_BROKER=\"prefect_redis.messaging\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` config`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` set`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` PREFECT_SERVER_EVENTS_MESSAGING_CACHE=\"prefect_redis.messaging\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` config`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` set`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` PREFECT_SERVER_EVENTS_CAUSAL_ORDERING=\"prefect_redis.ordering\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` config`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` set`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` PREFECT_SERVER_CONCURRENCY_LEASE_STORAGE=\"prefect_redis.lease_storage\"`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Configure Redis connection`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` PREFECT_REDIS_MESSAGING_HOST`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"redis\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` PREFECT_REDIS_MESSAGING_PORT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"6379\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` PREFECT_REDIS_MESSAGING_DB`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"0\"`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Start server with 4 workers`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`prefect`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` server`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` start`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --workers`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 4`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`For a complete Redis setup including authentication, TLS, and Docket coordination for\nbackground services, see `,_jsx(_components.a,{href:`/v3/advanced/self-hosted`,children:`How to scale self-hosted Prefect`}),`.`]}),`\n`,_jsx(Tip,{children:_jsx(_components.p,{children:`The number of workers should typically match the number of CPU cores available to your server process, but you may need to experiment to find the optimal value for your workload.`})}),`\n`,_jsx(Heading,{level:`2`,id:`advanced-configuration`,children:`Advanced configuration`}),`\n`,_jsx(_components.p,{children:`For advanced deployment scenarios including:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Running behind a reverse proxy`}),`\n`,_jsx(_components.li,{children:`Configuring SSL certificates`}),`\n`,_jsx(_components.li,{children:`Multi-server deployments`}),`\n`,_jsx(_components.li,{children:`Handling migration issues`}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/v3/advanced/self-hosted`,children:`How to scale self-hosted Prefect`}),`.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"How to run a local Prefect server","sidebarTitle":"Run a local Prefect server","description":"Get started with self-hosting by running Prefect server locally.","keywords":["self-hosted","server","CLI","local","prefect server start"],"href":"/v3/how-to-guides/self-hosted/server-cli"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Start the server","slug":"start-the-server","depth":2,"children":[]},{"title":"Configure the server","slug":"configure-the-server","depth":2,"children":[]},{"title":"Database configuration","slug":"database-configuration","depth":2,"children":[{"title":"Use SQLite (default)","slug":"use-sqlite-default","depth":3,"children":[]},{"title":"Use PostgreSQL","slug":"use-postgresql","depth":3,"children":[]}]},{"title":"Database management commands","slug":"database-management-commands","depth":2,"children":[{"title":"Reset the database","slug":"reset-the-database","depth":3,"children":[]},{"title":"Manage migrations","slug":"manage-migrations","depth":3,"children":[]}]},{"title":"Multi-worker API server","slug":"multi-worker-api-server","depth":2,"children":[{"title":"Requirements for multi-worker mode","slug":"requirements-for-multi-worker-mode","depth":3,"children":[]},{"title":"Configuration example","slug":"configuration-example","depth":3,"children":[]}]},{"title":"Advanced configuration","slug":"advanced-configuration","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/docs/_mintlify/custom/prefect-bd373955/4f3e55fa53d4a575/script.js","/docs/_mintlify/custom/prefect-bd373955/87a13774513287dd/osano.js","/docs/_mintlify/custom/prefect-bd373955/e7b7298d9b02df32/outbound-referrer.js"],"subdomain":"prefect-bd373955","siteName":"Prefect","title":"How to run a local Prefect server - Prefect","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-07-23T20:34:17.066Z","originalFileLocation":"v3/how-to-guides/self-hosted/server-cli.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"light\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Get started with self-hosting by running Prefect server locally.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Prefect\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/prefect-bd373955/QsizguCJ7nwtgDte/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/docs/mintlify-assets/_mintlify/favicons/prefect-bd373955/QsizguCJ7nwtgDte/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/prefect-bd373955/QsizguCJ7nwtgDte/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/prefect-bd373955/QsizguCJ7nwtgDte/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/prefect-bd373955/QsizguCJ7nwtgDte/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/prefect-bd373955/QsizguCJ7nwtgDte/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/prefect-bd373955/QsizguCJ7nwtgDte/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/prefect-bd373955/QsizguCJ7nwtgDte/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/prefect-bd373955/QsizguCJ7nwtgDte/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"How to run a local Prefect server - Prefect\">\u003cmeta data-mint-head property=\"og:description\" content=\"Get started with self-hosting by running Prefect server locally.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Prefect\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://www.prefect.io/docs/v3/how-to-guides/self-hosted/server-cli\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://prefect-bd373955.mintlify.site/docs/_mintlify/api/og/v2?division=Prefect+Self-hosted\u0026amp;title=How+to+run+a+local+Prefect+server\u0026amp;description=Get+started+with+self-hosting+by+running+Prefect+server+locally.\u0026amp;theme=ce2957f9cdece17b41396978\u0026amp;signature=d02fc3b140b31d01a4e3a8372f49ded4b048113745fda1ea94d72871a7c47e7a\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"How to run a local Prefect server - Prefect\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Get started with self-hosting by running Prefect server locally.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://prefect-bd373955.mintlify.site/docs/_mintlify/api/og/v2?division=Prefect+Self-hosted\u0026amp;title=How+to+run+a+local+Prefect+server\u0026amp;description=Get+started+with+self-hosting+by+running+Prefect+server+locally.\u0026amp;theme=ce2957f9cdece17b41396978\u0026amp;signature=d02fc3b140b31d01a4e3a8372f49ded4b048113745fda1ea94d72871a7c47e7a\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/docs/mintlify-assets/_mintlify/favicons/prefect-bd373955/QsizguCJ7nwtgDte/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Prefect\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#2D6DF6\">\u003clink data-mint-head rel=\"canonical\" href=\"https://www.prefect.io/docs/v3/how-to-guides/self-hosted/server-cli\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/v3/how-to-guides/self-hosted/server-cli.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://www.prefect.io/#organization\",\"name\":\"Prefect\",\"url\":\"https://www.prefect.io\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/prefect-bd373955/2_4m_dDmEdgqK7r9/logos/logo-wordmark-dark.svg?fit=max\u0026auto=format\u0026n=2_4m_dDmEdgqK7r9\u0026q=85\u0026s=076c95a93dbe29192ba9129faefcc878\"}},{\"@type\":\"WebSite\",\"@id\":\"https://www.prefect.io/docs#website\",\"name\":\"Prefect\",\"url\":\"https://www.prefect.io/docs\",\"publisher\":{\"@id\":\"https://www.prefect.io/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://www.prefect.io/docs/v3/how-to-guides/self-hosted/server-cli#webpage\",\"url\":\"https://www.prefect.io/docs/v3/how-to-guides/self-hosted/server-cli\",\"name\":\"How to run a local Prefect server\",\"description\":\"Get started with self-hosting by running Prefect server locally.\",\"dateModified\":\"2026-07-23T20:34:17.066Z\",\"isPartOf\":{\"@id\":\"https://www.prefect.io/docs#website\"},\"breadcrumb\":{\"@id\":\"https://www.prefect.io/docs/v3/how-to-guides/self-hosted/server-cli#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://www.prefect.io/docs/v3/how-to-guides/self-hosted/server-cli#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Prefect\",\"item\":\"https://www.prefect.io/docs\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to run a local Prefect server\",\"item\":\"https://www.prefect.io/docs/v3/how-to-guides/self-hosted/server-cli\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://www.prefect.io/docs/v3/how-to-guides/self-hosted/server-cli#article\",\"headline\":\"How to run a local Prefect server\",\"name\":\"How to run a local Prefect server\",\"description\":\"Get started with self-hosting by running Prefect server locally.\",\"url\":\"https://www.prefect.io/docs/v3/how-to-guides/self-hosted/server-cli\",\"mainEntityOfPage\":{\"@id\":\"https://www.prefect.io/docs/v3/how-to-guides/self-hosted/server-cli#webpage\"},\"dateModified\":\"2026-07-23T20:34:17.066Z\",\"keywords\":\"self-hosted, server, CLI, local, prefect server start\",\"publisher\":{\"@id\":\"https://www.prefect.io/#organization\"},\"isPartOf\":{\"@id\":\"https://www.prefect.io/docs#website\"}}]}\u003c/script>","siteName":"Prefect","nav":{"global":null,"tabs":[{"tab":"Getting Started","pages":[{"title":"Getting Started","href":"/v3/get-started"}]},{"tab":"Concepts","pages":[{"title":"Concepts","href":"/v3/concepts"}]},{"tab":"How-to Guides","pages":[{"title":"How-to Guides","sidebarTitle":"Overview","icon":"bars","href":"/v3/how-to-guides"},{"group":"Workflows","pages":[{"title":"How to write and run a workflow","sidebarTitle":"Write and run a workflow","href":"/v3/how-to-guides/workflows/write-and-run"},{"title":"How to use assets to track workflow outputs","sidebarTitle":"Use assets to track workflow outputs","href":"/v3/how-to-guides/workflows/assets"},{"title":"How to automatically rerun your workflow when it fails","sidebarTitle":"Automatically rerun a workflow when it fails","href":"/v3/how-to-guides/workflows/retries"},{"title":"How to manually retry a flow run","sidebarTitle":"Manually retry a flow run","href":"/v3/how-to-guides/workflows/retry-flow-runs"},{"title":"How to customize a workflow's metadata","sidebarTitle":"Customize workflow metadata","href":"/v3/how-to-guides/workflows/custom-metadata"},{"title":"How to pass inputs to a workflow","sidebarTitle":"Pass inputs to a workflow","href":"/v3/how-to-guides/workflows/pass-inputs"},{"title":"How to add logging to a workflow","sidebarTitle":"Add logging","href":"/v3/how-to-guides/workflows/add-logging"},{"title":"How to access runtime information","sidebarTitle":"Access runtime information","href":"/v3/how-to-guides/workflows/access-runtime-info"},{"title":"How to run work concurrently","sidebarTitle":"Run work concurrently","href":"/v3/how-to-guides/workflows/run-work-concurrently"},{"title":"How to cache workflow step outputs","sidebarTitle":"Cache workflow step outputs","href":"/v3/how-to-guides/workflows/cache-workflow-steps"},{"title":"How to run background tasks","sidebarTitle":"Run background tasks","href":"/v3/how-to-guides/workflows/run-background-tasks"},{"title":"How to respond to state changes","sidebarTitle":"Respond to state changes","href":"/v3/how-to-guides/workflows/state-change-hooks"},{"title":"How to produce workflow artifacts","sidebarTitle":"Create Artifacts","href":"/v3/how-to-guides/workflows/artifacts"},{"title":"How to test workflows","sidebarTitle":"Test workflows","href":"/v3/how-to-guides/workflows/test-workflows"},{"title":"How to apply global concurrency and rate limits","sidebarTitle":"Apply global concurrency and rate limits","href":"/v3/how-to-guides/workflows/global-concurrency-limits"},{"title":"How to limit concurrent task runs with tags","sidebarTitle":"Limit concurrent task runs with tags","href":"/v3/how-to-guides/workflows/tag-based-concurrency-limits"}]},{"group":"Deployments","pages":[{"title":"How to create deployments","sidebarTitle":"Create Deployments","href":"/v3/how-to-guides/deployments/create-deployments"},{"title":"Trigger ad-hoc deployment runs","href":"/v3/how-to-guides/deployments/run-deployments"},{"title":"How to create schedules","sidebarTitle":"Create Deployment Schedules","href":"/v3/how-to-guides/deployments/create-schedules"},{"title":"Manage Deployment schedules","sidebarTitle":"Manage Deployment schedules","href":"/v3/how-to-guides/deployments/manage-schedules"},{"title":"How to deploy flows with Python","sidebarTitle":"Deploy via Python","href":"/v3/how-to-guides/deployments/deploy-via-python"},{"title":"How to define deployments with YAML","sidebarTitle":"Define deployments with YAML","href":"/v3/how-to-guides/deployments/prefect-yaml"},{"title":"How to retrieve code from storage","sidebarTitle":"Retrieve code from storage","href":"/v3/how-to-guides/deployments/store-flow-code"},{"title":"How to version deployments","sidebarTitle":"Version Deployments","href":"/v3/how-to-guides/deployments/versioning"},{"title":"How to override job variables","sidebarTitle":"Override Job Variables","href":"/v3/how-to-guides/deployments/customize-job-variables"}]},{"group":"Configuration","pages":[{"title":"How to store secrets","sidebarTitle":"Store secrets","href":"/v3/how-to-guides/configuration/store-secrets"},{"title":"How to share configuration between workflows","sidebarTitle":"Share configuration between workflows","href":"/v3/how-to-guides/configuration/variables"},{"title":"How to manage settings","sidebarTitle":"Manage settings","href":"/v3/how-to-guides/configuration/manage-settings"}]},{"group":"Automations","pages":[{"title":"How to create automations","sidebarTitle":"Create Automations","href":"/v3/how-to-guides/automations/creating-automations"},{"title":"Custom notifications","href":"/v3/how-to-guides/automations/custom-notifications"},{"title":"How to create deployment triggers","sidebarTitle":"Create Deployment Triggers","href":"/v3/how-to-guides/automations/creating-deployment-triggers"},{"title":"How to chain deployments with events","sidebarTitle":"Chain Deployments with Events","href":"/v3/how-to-guides/automations/chaining-deployments-with-events"},{"title":"How to access deployment and flow run parameters","sidebarTitle":"Access parameters in templates","href":"/v3/how-to-guides/automations/access-parameters-in-templates"},{"title":"How to pass event payloads to flows","sidebarTitle":"Pass event payloads to flows","href":"/v3/how-to-guides/automations/passing-event-payloads-to-flows"}]},{"group":"Workflow Infrastructure","pages":[{"title":"How to manage work pools","sidebarTitle":"Manage Work Pools","href":"/v3/how-to-guides/deployment_infra/manage-work-pools"},{"title":"How to run flows in local processes","sidebarTitle":"Run Flows in Local Processes","href":"/v3/how-to-guides/deployment_infra/run-flows-in-local-processes"},{"group":"Managed Infrastructure","expanded":false,"pages":[{"title":"How to run flows on Prefect Managed infrastructure","sidebarTitle":"Run flows on Prefect Managed infrastructure","href":"/v3/how-to-guides/deployment_infra/managed"},{"title":"Using cloud workload identity with Prefect Managed work pools","sidebarTitle":"Using cloud workload identity","href":"/v3/how-to-guides/deployment_infra/managed-aws-federated-identity"}]},{"title":"How to run flows on serverless compute","sidebarTitle":"Run flows on serverless compute","href":"/v3/how-to-guides/deployment_infra/serverless"},{"title":"How to run flows in Docker containers","sidebarTitle":"Run flows in Docker containers","href":"/v3/how-to-guides/deployment_infra/docker"},{"title":"How to run flows in a long-lived Docker container","sidebarTitle":"Run flows in a static container","href":"/v3/how-to-guides/deployment_infra/serve-flows-docker"},{"title":"How to run flows on Kubernetes","sidebarTitle":"Run flows on Kubernetes","href":"/v3/how-to-guides/deployment_infra/kubernetes"},{"title":"How to run flows on Modal","sidebarTitle":"Run flows on Modal","href":"/v3/how-to-guides/deployment_infra/modal"},{"title":"How to run flows on Coiled","sidebarTitle":"Run flows on Coiled","href":"/v3/how-to-guides/deployment_infra/coiled"}]},{"group":"Prefect Cloud","pages":[{"title":"How to connect to Prefect Cloud","sidebarTitle":"Connect to Prefect Cloud","href":"/v3/how-to-guides/cloud/connect-to-cloud"},{"group":"Manage accounts","pages":[{"title":"How to manage user accounts","sidebarTitle":"Manage user accounts","href":"/v3/how-to-guides/cloud/manage-users/index"},{"title":"How to manage service accounts","sidebarTitle":"Manage service accounts","href":"/v3/how-to-guides/cloud/manage-users/service-accounts"},{"title":"How to manage teams","sidebarTitle":"Manage teams","href":"/v3/how-to-guides/cloud/manage-users/manage-teams"},{"title":"How to manage account roles","sidebarTitle":"Manage account roles","href":"/v3/how-to-guides/cloud/manage-users/manage-roles"},{"title":"How to manage API keys","sidebarTitle":"Manage API keys","href":"/v3/how-to-guides/cloud/manage-users/api-keys"},{"title":"How to configure single sign-on","sidebarTitle":"Configure single sign-on","href":"/v3/how-to-guides/cloud/manage-users/configure-sso"},{"title":"How to audit Cloud activity","sidebarTitle":"Audit Cloud activity","href":"/v3/how-to-guides/cloud/manage-users/audit-logs"},{"title":"How to manage Access Control Lists (ACLs)","sidebarTitle":"Access Control Lists (ACLs)","href":"/v3/how-to-guides/cloud/manage-users/object-access-control-lists"},{"title":"How to secure access by IP address","sidebarTitle":"Secure access by IP address","href":"/v3/how-to-guides/cloud/manage-users/secure-access-by-ip-address"},{"title":"How to secure access over PrivateLink","sidebarTitle":"Secure access over PrivateLink","href":"/v3/how-to-guides/cloud/manage-users/secure-access-by-private-link"}]},{"title":"How to manage workspaces","sidebarTitle":"Manage Workspaces","href":"/v3/how-to-guides/cloud/workspaces"},{"title":"How to create a webhook","sidebarTitle":"Create a Webhook","href":"/v3/how-to-guides/cloud/create-a-webhook"},{"title":"How to troubleshoot Prefect Cloud","sidebarTitle":"Troubleshoot Prefect Cloud","href":"/v3/how-to-guides/cloud/troubleshoot-cloud"},{"title":"Prefect scope of support","sidebarTitle":"Scope of support","description":"Understand what Prefect support covers and where to find help for requests outside its scope.","href":"/v3/how-to-guides/cloud/scope-of-support"}]},{"group":"Prefect Self-hosted","pages":[{"title":"How to run a local Prefect server","sidebarTitle":"Run a local Prefect server","href":"/v3/how-to-guides/self-hosted/server-cli"},{"title":"How to run the Prefect server in Docker","sidebarTitle":"Run the Prefect server in Docker","description":"Run a containerized Prefect server instance with Docker.","href":"/v3/how-to-guides/self-hosted/server-docker"},{"title":"How to run Prefect on Windows","sidebarTitle":"Run Prefect on Windows","href":"/v3/how-to-guides/self-hosted/server-windows"},{"title":"How to run the Prefect Server via Docker Compose","sidebarTitle":"Run the Prefect Server via Docker Compose","href":"/v3/how-to-guides/self-hosted/docker-compose"}]},{"group":"AI","pages":[{"title":"AI assistants with Prefect MCP","sidebarTitle":"Overview","icon":"robot","href":"/v3/how-to-guides/ai/index"},{"title":"How to use the Prefect MCP server","sidebarTitle":"Use the Prefect MCP server","href":"/v3/how-to-guides/ai/use-prefect-mcp-server"},{"title":"AI log summaries","sidebarTitle":"AI log summaries","href":"/v3/how-to-guides/ai/flow-run-log-summaries"}]},{"group":"Migrate","pages":[{"title":"How to Migrate from Airflow","sidebarTitle":"Migrate from Airflow","href":"/v3/how-to-guides/migrate/airflow"},{"title":"How to upgrade to Prefect 3.0","sidebarTitle":"Upgrade to Prefect 3.0","href":"/v3/how-to-guides/migrate/upgrade-to-prefect-3"},{"title":"How to upgrade from agents to workers","sidebarTitle":"Upgrade from agents to workers","href":"/v3/how-to-guides/migrate/upgrade-agents-to-workers"},{"title":"How to transfer resources between Prefect environments","sidebarTitle":"Transfer resources between environments","href":"/v3/how-to-guides/migrate/transfer-resources"}]}]},{"tab":"Advanced","pages":[{"title":"Advanced","href":"/v3/advanced"}]},{"tab":"Examples","pages":[{"title":"Examples","href":"/v3/examples"}]},{"tab":"Integrations","pages":[{"title":"Integrations","href":"/integrations/integrations"}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/v3/api-ref"}]},{"tab":"Contribute","pages":[{"title":"Contribute","href":"/contribute"}]},{"tab":"Release Notes","pages":[{"title":"Release Notes","href":"/v3/release-notes"}]}]},"basePath":"","title":"How to run a local Prefect server - Prefect","buildId":"dpl_ATnXPMW25DMPUr9VBw6kL6MfBt6T","deploymentId":"dpl_ATnXPMW25DMPUr9VBw6kL6MfBt6T","dynamics":["a74be98ba7"],"chunks":["zoom-image-lightbox-CypZe82l.js","lightbox-handle-r17bVUz3.js"]}