<@ULVA73B9P> my prefect service file Unit] Description=Prefect Server After=network-online.target po...
s
@Marvin my prefect service file Unit] Description=Prefect Server After=network-online.target postgresql.service Wants=network-online.target [Service] Type=simple User=root WorkingDirectory=/home/prefect Environment="PREFECT_HOME=/home/prefect/.prefect" Environment="PREFECT_SERVER_API_HOST=192.168.29.151" Environment="PREFECT_SERVER_API_PORT=4200" Environment="PREFECT_SERVER_API_KEEPALIVE_TIMEOUT=60" Environment="PREFECT_SERVER_LOGGING_LEVEL=DEBUG" Environment="PREFECT_API_DATABASE_CONNECTION_URL=postgresql+asyncpg://prefect:Network%405714@127.0.0.1:5432/prefect" Environment="PREFECT_SERVER_API_AUTH_STRING=astra:Network@5714" ExecStart=/home/prefect/.venv/bin/prefect server start --host 0.0.0.0 --port 4200 --keep-alive-timeout 60 Restart=on-failure RestartSec=10 StandardOutput=journal StandardError=journal [Install] WantedBy=multi-user.target but still my prefect is showing (.venv) root@Prefect:/home/prefect# prefect config view 🚀 you are connected to: 192.168.29.151 PREFECT_PROFILE='server' PREFECT_API_AUTH_STRING='********' (from profile) PREFECT_API_URL='192.168.29.151/api' (from profile) (.venv) root@Prefect:/home/prefect# sudo nano /etc/systemd/system/prefect-server.service(.venv) root@Prefect:/home/prefect# prefect version Version: 3.6.15 API version: 0.8.4 Python version: 3.12.3 Git commit: 757a089b Built: Fri, Jan 30, 2026 12:27 AM OS/Arch: linux/x86_64 Profile: server Server type: server Pydantic version: 2.12.5 Server: Database: sqlite SQLite version: 3.45.1 Integrations: prefect-docker: 0.7.1 (.venv) root@Prefect:/home/prefect#
m
✅ thought for 164.2 seconds
A couple things stand out immediately: 1. Your systemd unit file is malformed at the top You pasted:
Copy code
ini
my prefect service file Unit]
Description=Prefect Server
It must start with:
Copy code
ini
[Unit]
Description=Prefect Server
If
[Unit]
is wrong or missing, systemd may not be reading the unit as expected. 2. This line is wrong because of the angle brackets around the whole value
Copy code
ini
Environment="PREFECT_API_DATABASE_CONNECTION_URL=<postgresql+asyncpg://prefect:Network%405714@127.0.0.1:5432/prefect>"
It should be:
Copy code
ini
Environment="PREFECT_API_DATABASE_CONNECTION_URL=<postgresql+asyncpg://prefect:Network%405714@127.0.0.1:5432/prefect>"
Do not wrap the URL in
< >
. Those become literal characters in the value, which will break parsing. 3.
prefect config view
is showing your CLI profile, not necessarily the systemd service environment
So this output:
Copy code
bash
prefect config view
only tells you what your shell session sees. It does not prove the systemd service got the same env vars. 4. If
prefect version
shows
Database: sqlite
, your current shell does not have the Postgres DB setting applied
That means either: - the env var is only in systemd and not in your shell - or the service file is not being loaded correctly - or the DB URL value is invalid Your current
prefect version
output strongly suggests Prefect is falling back to SQLite. Recommended fixed unit file
Copy code
ini
[Unit]
Description=Prefect Server
After=network-online.target postgresql.service
Wants=network-online.target

[Service]
Type=simple
User=root
WorkingDirectory=/home/prefect
Environment="PREFECT_HOME=/home/prefect/.prefect"
Environment="PREFECT_SERVER_API_HOST=192.168.29.151"
Environment="PREFECT_SERVER_API_PORT=4200"
Environment="PREFECT_SERVER_API_KEEPALIVE_TIMEOUT=60"
Environment="PREFECT_SERVER_LOGGING_LEVEL=DEBUG"
Environment="PREFECT_API_DATABASE_CONNECTION_URL=<postgresql+asyncpg://prefect:Network%405714@127.0.0.1:5432/prefect>"
Environment="PREFECT_SERVER_API_AUTH_STRING=astra:Network@5714"

ExecStart=/home/prefect/.venv/bin/prefect server start --host 0.0.0.0 --port 4200 --keep-alive-timeout 60

Restart=on-failure
RestartSec=10
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target
Then reload and restart systemd
Copy code
bash
sudo systemctl daemon-reload
sudo systemctl restart prefect-server
sudo systemctl status prefect-server
Check what environment systemd actually loaded
Copy code
bash
sudo systemctl show prefect-server --property=Environment
You should see
PREFECT_API_DATABASE_CONNECTION_URL=postgresql+asyncpg://...
Check service logs
Copy code
bash
journalctl -u prefect-server -n 100 --no-pager
If the DB URL is bad, Prefect usually logs startup/database errors there. Test the DB setting directly in your shell This is the fastest way to confirm the setting itself works:
Copy code
bash
export PREFECT_API_DATABASE_CONNECTION_URL="<postgresql+asyncpg://prefect:Network%405714@127.0.0.1:5432/prefect>"
prefect version
If that is correct,
prefect version
should stop showing SQLite. Important note about auth vars For a server process,
PREFECT_SERVER_API_AUTH_STRING
is the right server-side setting. For CLI/client access,
PREFECT_API_AUTH_STRING
is the client-side setting. So if you want your shell CLI to authenticate too, you may also need:
Copy code
bash
export PREFECT_API_AUTH_STRING="astra:Network@5714"
Docs - Settings and profiles - Self-hosted Prefect - Security settings If you want, I can help you with a step-by-step verification checklist for this exact server so we can pinpoint whether the issue is: - bad unit syntax - bad env var value - systemd not reloading - or Postgres connection failure.
s
@Marvin still same tired of this issue (.venv) root@Prefect:/home/prefect# prefect version Version: 3.6.15 API version: 0.8.4 Python version: 3.12.3 Git commit: 757a089b Built: Fri, Jan 30, 2026 12:27 AM OS/Arch: linux/x86_64 Profile: server Server type: server Pydantic version: 2.12.5 Server: Database: sqlite SQLite version: 3.45.1 Integrations: prefect-docker: 0.7.1 (.venv) root@Prefect:/home/prefect#
m
✅ thought for 12.9 seconds
I think the key point is this:
prefect version
is checking your current shell environment/profile, not proving what the systemd service is using.
So if you run:
Copy code
bash
prefect version
and it shows SQLite, that only means your shell session is still configured for SQLite. Let’s stop guessing and test this in the shortest possible way. Run these exact commands in your shell:
Copy code
bash
export PREFECT_API_DATABASE_CONNECTION_URL="<postgresql+asyncpg://prefect:Network%405714@127.0.0.1:5432/prefect>"
prefect version
If it still says SQLite after that, then one of these is true: - the variable name is not being honored in your environment - the URL is invalid - Prefect is ignoring it because another setting is overriding it - or the command is not reading what we expect Then try this too:
Copy code
bash
export PREFECT_SERVER_DATABASE_CONNECTION_URL="<postgresql+asyncpg://prefect:Network%405714@127.0.0.1:5432/prefect>"
prefect version
If both still show SQLite, then don’t focus on systemd yet. The issue is reproducible directly in the shell. Next, inspect the active config value directly:
Copy code
bash
prefect config view --show-sources
Look specifically for anything related to database connection settings. Also run:
Copy code
bash
env | grep PREFECT
That will show exactly what Prefect-related env vars are present in your current shell. Most likely problem in your case Your output shows:
Copy code
bash
Profile: server
Server type: server
Server:
  Database: sqlite
That suggests the active profile is still configured for local SQLite, and your shell does not actually have the DB env var set. Also, your service file used this earlier:
Copy code
ini
Environment="PREFECT_API_DATABASE_CONNECTION_URL=<postgresql+asyncpg://...>"
Those
< >
absolutely make the value wrong. If systemd loaded that, Prefect would not parse it as a valid connection URL. What I want you to run now
Copy code
bash
export PREFECT_API_DATABASE_CONNECTION_URL="<postgresql+asyncpg://prefect:Network%405714@127.0.0.1:5432/prefect>"
env | grep PREFECT_API_DATABASE_CONNECTION_URL
prefect config view --show-sources
prefect version
And for systemd:
Copy code
bash
sudo systemctl daemon-reload
sudo systemctl restart prefect-server
sudo systemctl show prefect-server --property=Environment
journalctl -u prefect-server -n 100 --no-pager
Important reality check If the server process is using Postgres correctly,
prefect version
in your shell can still show SQLite unless you also exported the same DB env var in that shell. So the better question is: Is the running server actually using SQLite or Postgres? To verify that, check the server logs after restart. If it connects to Postgres, logs will show DB migration/connection behavior. If it falls back or fails, the journal will show why. If you want, send me the output of just these 3 commands:
Copy code
bash
env | grep PREFECT
prefect config view --show-sources
sudo systemctl show prefect-server --property=Environment
and I’ll tell you exactly where it’s going wrong.
s
@Marvin (.venv) root@Prefect:/home/prefect# prefect version Version: 3.6.15 API version: 0.8.4 Python version: 3.12.3 Git commit: 757a089b Built: Fri, Jan 30, 2026 12:27 AM OS/Arch: linux/x86_64 Profile: server Server type: server Pydantic version: 2.12.5 Server: Database: postgresql PostgreSQL version: 16.14 (Ubuntu 16.14-0ubuntu0.24.04.1) Integrations: prefect-docker: 0.7.1 (.venv) root@Prefect:/home/prefect#
m
✅ thought for 7.0 seconds
Great — that means it’s working now. Your latest output confirms Prefect is using PostgreSQL:
Copy code
bash
Server:
  Database:           postgresql
  PostgreSQL version: 16.14
So the original problem is resolved. What changed? Most likely one of these fixed it: - removing the invalid
< >
around the DB URL - exporting the correct environment variable - reloading/restarting systemd - correcting the service file formatting What this means Your Prefect server is no longer using SQLite fallback. It is now connected to Postgres as intended. Recommended next checks
Copy code
bash
sudo systemctl status prefect-server
journalctl -u prefect-server -n 50 --no-pager
And if you want to verify the UI/API is healthy:
Copy code
bash
curl <http://192.168.29.151:4200/api/health>
You should get a healthy response. Suggestion Now that it works, save the final clean unit file and avoid editing it further unless necessary. If you want, I can help you with a production-ready Prefect systemd service file next, including: - running as a non-root user - auto-restart - environment file usage - safer secrets handling - log tuning
s
@Marvin still something going wrong (.venv) root@Prefect:/home/prefect# prefect version Version: 3.6.15 API version: 0.8.4 Python version: 3.12.3 Git commit: 757a089b Built: Fri, Jan 30, 2026 12:27 AM OS/Arch: linux/x86_64 Profile: server Server type: server Pydantic version: 2.12.5 Server: Database: postgresql PostgreSQL version: 16.14 (Ubuntu 16.14-0ubuntu0.24.04.1) Integrations: prefect-docker: 0.7.1 p(.venv) root@Prefect:/home/prefect# prefect config view 🚀 you are connected to: 192.168.29.151 PREFECT_PROFILE='server' PREFECT_API_AUTH_STRING='********' (from profile) PREFECT_API_DATABASE_CONNECTION_URL='********' (from env) PREFECT_API_URL='192.168.29.151/api' (from profile) (.venv) root@Prefect:/home/prefect# cat /etc/systemd/system/prefect-server.service [Unit] Description=Prefect Server After=network-online.target postgresql.service Wants=network-online.target [Service] Type=simple User=root WorkingDirectory=/home/prefect Environment="PREFECT_HOME=/home/prefect/.prefect" Environment="PREFECT_SERVER_API_HOST=192.168.29.151" Environment="PREFECT_SERVER_API_PORT=4200" Environment="PREFECT_SERVER_API_KEEPALIVE_TIMEOUT=60" Environment="PREFECT_SERVER_LOGGING_LEVEL=DEBUG" Environment="PREFECT_API_DATABASE_CONNECTION_URL=postgresql+asyncpg://prefect:Network%405714@127.0.0.1:5432/prefect" Environment="PREFECT_SERVER_API_AUTH_STRING=astra:Network@5714" ExecStart=/home/prefect/.venv/bin/prefect server start --host 0.0.0.0 --port 4200 --keep-alive-timeout 60 Restart=on-failure RestartSec=10 StandardOutput=journal StandardError=journal [Install] WantedBy=multi-user.target (.venv) root@Prefect:/home/prefect#
m
✅ thought for 11.7 seconds
Yes — there is still a problem in the systemd service file. Your shell is using Postgres, but your service file still contains the broken DB URL:
Copy code
ini
Environment="PREFECT_API_DATABASE_CONNECTION_URL=<postgresql+asyncpg://prefect:Network%405714@127.0.0.1:5432/prefect>"
Those
< >
should not be there. So right now: - your shell is using a correct env var, which is why
prefect version
shows PostgreSQL - but systemd service is still configured with an invalid value That means the running service may fail on restart or may not be using the config you think it is. Fix this exact line Change:
Copy code
ini
Environment="PREFECT_API_DATABASE_CONNECTION_URL=<postgresql+asyncpg://prefect:Network%405714@127.0.0.1:5432/prefect>"
To:
Copy code
ini
Environment="PREFECT_API_DATABASE_CONNECTION_URL=<postgresql+asyncpg://prefect:Network%405714@127.0.0.1:5432/prefect>"
Then reload and restart:
Copy code
bash
sudo systemctl daemon-reload
sudo systemctl restart prefect-server
sudo systemctl status prefect-server
Then verify what systemd actually loaded:
Copy code
bash
sudo systemctl show prefect-server --property=Environment
Then check logs:
Copy code
bash
journalctl -u prefect-server -n 100 --no-pager
Important distinction Your
prefect config view
says:
Copy code
bash
PREFECT_API_DATABASE_CONNECTION_URL='****' (from env)
That only confirms your current shell has the env var. It does not confirm the
prefect-server.service
file is correct. And we can see directly from
cat /etc/systemd/system/prefect-server.service
that the service file is still wrong. Correct full unit file
Copy code
ini
[Unit]
Description=Prefect Server
After=network-online.target postgresql.service
Wants=network-online.target

[Service]
Type=simple
User=root
WorkingDirectory=/home/prefect
Environment="PREFECT_HOME=/home/prefect/.prefect"
Environment="PREFECT_SERVER_API_HOST=192.168.29.151"
Environment="PREFECT_SERVER_API_PORT=4200"
Environment="PREFECT_SERVER_API_KEEPALIVE_TIMEOUT=60"
Environment="PREFECT_SERVER_LOGGING_LEVEL=DEBUG"
Environment="PREFECT_API_DATABASE_CONNECTION_URL=<postgresql+asyncpg://prefect:Network%405714@127.0.0.1:5432/prefect>"
Environment="PREFECT_SERVER_API_AUTH_STRING=astra:Network@5714"
ExecStart=/home/prefect/.venv/bin/prefect server start --host 0.0.0.0 --port 4200 --keep-alive-timeout 60
Restart=on-failure
RestartSec=10
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target
One more thing You may also want to make the CLI auth consistent in your shell by setting:
Copy code
bash
export PREFECT_API_AUTH_STRING="astra:Network@5714"
because the service uses
PREFECT_SERVER_API_AUTH_STRING
, while your CLI reads
PREFECT_API_AUTH_STRING
. If you want, I can give you the exact nano edit commands and a final verified service file using an
EnvironmentFile=
instead, which is cleaner and much less error-prone.
s
@Marvin (.venv) root@Prefect:/home/prefect# systemctl show prefect --property=Environment Environment= (.venv) root@Prefect:/home/prefect#
m
✅ thought for 11.1 seconds
You checked the wrong unit name. Your file is:
Copy code
bash
/etc/systemd/system/prefect-server.service
So the service name is
prefect-server
, not
prefect
. That’s why this showed nothing:
Copy code
bash
systemctl show prefect --property=Environment
Use:
Copy code
bash
systemctl show prefect-server --property=Environment
Also, because your service file still contains the bad DB URL with
< >
, fix that first. Do this exactly:
Copy code
bash
sudo nano /etc/systemd/system/prefect-server.service
Replace this line:
Copy code
ini
Environment="PREFECT_API_DATABASE_CONNECTION_URL=<postgresql+asyncpg://prefect:Network%405714@127.0.0.1:5432/prefect>"
with:
Copy code
ini
Environment="PREFECT_API_DATABASE_CONNECTION_URL=<postgresql+asyncpg://prefect:Network%405714@127.0.0.1:5432/prefect>"
Then run:
Copy code
bash
sudo systemctl daemon-reload
sudo systemctl restart prefect-server
sudo systemctl show prefect-server --property=Environment
sudo systemctl status prefect-server
journalctl -u prefect-server -n 50 --no-pager
What you should expect In the
systemctl show prefect-server --property=Environment
output, you should see something like:
Copy code
bash
Environment=PREFECT_HOME=/home/prefect/.prefect PREFECT_SERVER_API_HOST=192.168.29.151 ...
including the DB URL without angle brackets. Bottom line Right now your shell config is okay, but your systemd service config is still wrong and you queried the wrong service name. If you want, paste the output of:
Copy code
bash
systemctl show prefect-server --property=Environment
systemctl status prefect-server --no-pager
journalctl -u prefect-server -n 50 --no-pager
and I’ll tell you immediately whether the service is truly running with Postgres.
s
@Marvin how to verify prefect is running on postgres or sqlite
m
✅ thought for 96.1 seconds
You can verify it a few different ways. Fastest check
Copy code
bash
prefect version
Look for:
Copy code
bash
Server:
  Database:           postgresql
or
Copy code
bash
Server:
  Database:           sqlite
In your latest output, it already shows:
Copy code
bash
Server:
  Database:           postgresql
So your current Prefect environment is using PostgreSQL. Check the configured DB URL
Copy code
bash
prefect config view --show-secrets | grep -i database
You should see something like:
Copy code
bash
PREFECT_API_DATABASE_CONNECTION_URL='postgresql+asyncpg://...'
If it says
sqlite+aiosqlite:///...
, then it is using SQLite. If Prefect is running as a systemd service Check what the service is configured with:
Copy code
bash
systemctl show prefect-server --property=Environment
If you see:
Copy code
bash
PREFECT_API_DATABASE_CONNECTION_URL=postgresql+asyncpg://...
then the service is configured for Postgres. If nothing appears, or it shows a SQLite path, then the service is not configured the way you expect. Best runtime verification from logs
Copy code
bash
journalctl -u prefect-server -n 100 --no-pager
This helps confirm what the running service is actually doing when it starts. Most important caveat There are two different things: 1. Your shell / CLI config - checked by
prefect version
- checked by
prefect config view
2. Your running systemd service config - checked by
systemctl show prefect-server --property=Environment
- checked by
journalctl -u prefect-server
So if you want to know whether the service is on Postgres or SQLite, don’t rely only on your shell. For your case From what you already posted:
Copy code
bash
prefect version
...
Server:
  Database:           postgresql
That confirms the Prefect process in your current shell is using PostgreSQL. But your systemd file still showed this broken line:
Copy code
ini
Environment="PREFECT_API_DATABASE_CONNECTION_URL=<postgresql+asyncpg://...>"
So to verify the service specifically, run:
Copy code
bash
systemctl show prefect-server --property=Environment
journalctl -u prefect-server -n 50 --no-pager
If you want, I can give you a 3-command exact check to prove whether the running service is on PostgreSQL or SQLite.