Leaked an API key? › Postgres
Leaked DATABASE_URL: what to do in the next 10 minutes
Last updated: November 27, 2026. Steps checked against Postgres's own docs on November 27, 2026.
Short answer: Reset the database password at your host so the leaked connection string stops working for new connections. In Supabase, use Database Settings or Reset database password in the Connect dialog. In Neon, open the branch, go to Roles, choose Reset password, then copy the new string from Connect. On other Postgres hosts, use the dashboard or ALTER ROLE; PostgreSQL's docs recommend psql's \password command so the password is not left in client history or server logs. Put the new string only in a server-only DATABASE_URL variable everywhere it is set, then redeploy. A frontend app should not use a connection string: Supabase says to use the Data API instead. A free SniffPup scan of a site you own can flag a database connection string with a password in public JavaScript or an exposed environment file, but it cannot confirm the string is absent everywhere or see your database. Removing the string from code alone does not un-leak it.
Which Postgres keys are secret?
- Secret: A Postgres connection string that includes a password, often stored as DATABASE_URL. It looks like postgres:// or postgresql:// followed by a username, a password, a host, and a database name. Anyone who has it can try to connect as that role.
- Secret: The free scan also flags mysql://, mongodb://, mongodb+srv://, redis://, and rediss:// strings that include a password in the same username:password@host shape. Treat those as secrets too and rotate them at their host.
- Meant to be public: None. A connection string with a password is a secret. On Supabase, a frontend should use the Data API or client library with the anon or publishable key (which is meant to be public) and Row Level Security, not a DATABASE_URL.
The next 10 minutes
Times are a rough guide. Do the first step before anything else.
1. Reset the database password at the host (Minutes 0-2)
- Look at the leaked string to see which host it points at (for example a supabase.co, neon.tech, or other Postgres host). Then reset the password there. Changing only the copy in your repo does not revoke it.
- Supabase: reset the password from Database > Settings, or use Reset database password in the Connect dialog at the top of the project. Supabase says the dashboard does not show the database password after you create the project, and that a reset breaks existing connections that use the old password. After a reset, shared-pooler connections can fail briefly with password authentication failed; Supabase says this can be expected and retrying with the new password usually succeeds.
- Neon: in the Console, select the project and the branch, open Roles under Postgres database, choose Reset password from the role's menu, then click Reset. Copy the updated connection string from Connect in the nav. Neon says a connection string is built from the role, password, hostname, and database name, and that only the password segment changes. Neon also says already-open sessions can stay connected, and that any new connection with the old password fails. Roles are branch-scoped, so reset the role on every branch where it can log in.
- Other Postgres hosts: change the role password in the host's dashboard, or with ALTER ROLE ... PASSWORD. PostgreSQL's docs caution that an unencrypted password in ALTER ROLE may be sent in cleartext and may be logged, and they recommend psql's \password command instead.
2. Update DATABASE_URL everywhere and redeploy (Minutes 2-5)
- Put the new connection string in a server-only DATABASE_URL (or your host's secret store) everywhere it lives: your local .env, your host's environment variables for each environment (for example Vercel, Render, Fly.io, or Railway), your CI/CD secrets, and any scripts. Keep it server-only. Never put it in client JavaScript, a mobile app, a public repository, or a VITE_ or NEXT_PUBLIC_ variable.
- If this is a Supabase project, a frontend app does not need a connection string. Supabase says to use the Data API or client libraries, which need Row Level Security.
- Remove the leaked string from client code and build inputs, then redeploy so the new string takes effect. Check that the files your site serves no longer contain it.
- Know every place the old value lives before you reset, so you can roll out the new one right away. Neon says application logs that show password authentication failed can flag a location you missed.
3. Check for access you didn't authorize, and tighten access (Minutes 5-8)
- In your database dashboard or with a SQL client, look over roles, tables, and recent changes for anything your app didn't make, and note times. That is our advice.
- If the leaked string was a Neon credential, Neon says to reset the password for every role that can log in, starting with the default role, on every affected branch; roll the new strings out to every secret store; revoke any exposed Neon API keys; tighten the IP allowlist; and remove roles you do not recognize.
- If you need to keep the old string working until every consumer is updated, Neon describes creating a second role with the same access, moving consumers over, then resetting the old role's password. Resetting the password is what closes the leak.
4. Clean up the leaked string (Minutes 8-10)
- Remove the string from frontend code, public files, screenshots, CI logs, and git history. History can keep a secret after the file is deleted. Rotate any other secrets that sat in the same file or commit.
- Deleting the string from a repo does not revoke it. Only changing the password at the database does.
- Re-scan the live site you own. A clean report is not a guarantee of security. Don't paste the full connection string into chat.
Good to know
- The free scan looks for connection strings with a password in the public page and JavaScript it can see (postgres, postgresql, mysql, mongodb, redis, and rediss). It also flags when a public env name such as VITE_ or NEXT_PUBLIC_ looks like DATABASE_URL or DB_URL; in that case it reports the name, not the value. It also checks whether environment files such as /.env and Git metadata such as /.git/config are publicly downloadable. It cannot see private server environment variables, git history, or whether someone already connected with the leaked string.
- Putting a new DATABASE_URL into a public bundle or a public .env file exposes the new string the same way.
- The scan is passive and read-only on a live URL you own or are authorized to test. It is not a security guarantee.
After the first 10 minutes
Move the code that needs the key to the server (an API route, serverless function or Supabase Edge Function), keep the key in a server-only environment variable, redeploy, and re-check your live site. The general plan, with a prompt you can paste into Lovable, Bolt, Cursor or Claude Code, is in I leaked an API key in my vibe-coded app. What do I do now? Not sure what kind of key you found? Check it with What kind of key is this?
What SniffPup checks, and what it doesn't
A free SniffPup scan reads only what your live site serves to the public: secret key patterns in HTML and same-origin JavaScript (masked in the report) and public files such as /.env and /.git/config. It never uses a key it finds. It can't see your repo, your server or Postgres's logs, so the steps above are always on you. A clean report is not a guarantee of security.
Sources
- Supabase Docs: Connect to your database
- Supabase: How do I reset my Supabase database password?
- Neon FAQ: How do I rotate my Neon database connection string for security purposes?
- Neon Docs: Security overview (rotate credentials)
- PostgreSQL Docs: ALTER ROLE
Postgres can change its dashboard and steps at any time. If something here doesn't match what you see, follow Postgres's docs and tell us.
Other providers
- Leaked OpenAI API key: what to do in the next 10 minutes
- Leaked Anthropic API key: what to do in the next 10 minutes
- Leaked Gemini API key: what to do in the next 10 minutes
- Leaked Resend API key: what to do in the next 10 minutes
- Leaked Perplexity API key: what to do in the next 10 minutes
- Leaked OpenRouter API key: what to do in the next 10 minutes
- Leaked Groq API key: what to do in the next 10 minutes
- Leaked ElevenLabs API key (unauthorized charges): what to do
- Leaked Stripe secret key: what to do in the next 10 minutes
- Leaked Supabase service_role or secret key: next 10 minutes
- Leaked AWS access key: what to do in the next 10 minutes
- Leaked GitHub token: what to do in the next 10 minutes
- Leaked Twilio auth token: what to do in the next 10 minutes
- Leaked Clerk secret key: what to do in the next 10 minutes
- Leaked SendGrid API key: what to do in the next 10 minutes