- Why a normal terminal command says "Missing DATABASE_URL"
- One click: App settings → Run a command
- In the Terminal or over SSH: cn-env
- Prisma on a live site
- Good to know
Why a normal terminal command says "Missing DATABASE_URL"
Your environment variables (App settings → Environment variables) are given to your running app, not to every terminal session. A command such as npm run prisma:generate reads DATABASE_URL and the other settings, so it needs them too.
One click: App settings → Run a command
Open App settings, choose the app, and find Run a command in the Deploy card. Every script in your package.json has a button (long-running ones like dev and start are left out), and you can type any other command. It runs in your app folder with your variables, and the output appears below.
In the Terminal or over SSH: cn-env
Put cn-env in front of the command. Inside ~/web/yourdomain.com/ it uses that site's variables; elsewhere add -d yourdomain.com. cn-env on its own lists the variable names.
cd ~/web/yourdomain.com/app
cn-env npm run cms:seed
cn-env npx prisma migrate deploy
cn-env -d yourdomain.com python manage.py migratePrisma on a live site
- Use Apply database migrations (
prisma migrate deploy) — it applies the migrations in your repository and never deletes data. prisma migrate devis for your own computer: it needs rights to create a temporary database and can reset data, so it fails or is unsafe on a live server.prisma generateand the build run automatically on every Git deploy.
Good to know
- Commands run as your own account, with the same access as the Terminal, for up to 15 minutes.
- Builds and restarts are done by Deploy (or Git deployments); you rarely need
npm run buildby hand. - To create an admin with a script, add its variables (for example ADMIN_EMAIL and ADMIN_PASSWORD) in Environment variables first, run it, then remove the password variable again.
Stuck? Our engineers answer support tickets around the clock. Contact us, or create an account and open a ticket from the dashboard — the same guides are there too.