When you store a database URI in your Zsh environment, every small misstep can turn into a long night of debugging. A missing quote. An unescaped character. An environment that quietly refuses to load what you expect. Zsh, with its different parsing rules, will happily interpret your URI in ways you don’t.
A database URI often contains special characters. Symbols like ?, &, %, and @ mean something to the shell. In Zsh, unquoted values can vanish or break. This is where developers lose hours. You need to guard the URI correctly so the shell passes it as a single value to your application.
The safest route: enclose the full URI in single quotes when exporting it.
export DATABASE_URL='postgresql://user:pass@host:5432/dbname?sslmode=require'
If your URI has single quotes inside, escape them or switch to double quotes and escape $ when it appears in the password or query string.
In .zshrc, persistence matters. But remember: after editing, you must reload the shell or run source ~/.zshrc for the changes to apply. Without it, nothing changes—Zsh doesn’t guess your intent.