AppInspected

Fix guides

Your database password is in your website's code. Change it, end the old sessions, then lock the door.

Last reviewed October 31, 2026 against the providers' current documentation.

The short version

Reset the database user's password now: Supabase under Database → Settings, Neon under Roles → Reset password on each branch, MongoDB Atlas under Database & Network Access → Database Users → Edit, or \password in psql / ALTER USER … IDENTIFIED BY in MySQL on your own server. A password change doesn't close connections that are already open, so look for unknown sessions and end them. Then limit which IP addresses can reach the database, put the new URL only in your server's environment, and check your tables for data that was read, changed or deleted.

Why it matters

A connection string like postgres://user:password@host:5432/db is a complete login: host, user name and password. Whoever copies it from your JavaScript can connect with any Postgres, MySQL or MongoDB client and run whatever that user is allowed to run, usually everything, because the URL an app is set up with is often the owner or admin user. Nothing in your app stands in the way: no login screen, no Row Level Security if the user owns the tables or bypasses it, no rate limits. They can download every table, including users' emails and password hashes, change records, or drop the database.

Fix it, in this order

  1. Find the user and where it's used

    The part between // and : is the database user. Search your code and hosting settings for every place this URL or password is set (DATABASE_URL, VITE_DATABASE_URL, NEXT_PUBLIC_ variables, Prisma or Drizzle config), because each of them will need the new password. If several apps share this user, they all break when you change it; that's still the right call.
  2. Change the password

    Supabase: reset the database password in the dashboard under Database → Settings; Supabase notes that connections through its shared pooler may briefly fail with error 28P01 right after a reset, and retrying with the new password works. Neon: select the branch, open Roles, choose Reset password from the role's menu and copy the new connection string from Connect; passwords are set per branch, so reset it on every branch whose URL leaked. MongoDB Atlas: Database & Network Access → Database Users, Edit the user, edit the password, then Update User. Your own Postgres: use \password username in psql; the Postgres docs warn that ALTER ROLE … PASSWORD '…' can leave the new password in your command history or the server log. Your own MySQL: ALTER USER 'user'@'host' IDENTIFIED BY '…'; don't use RETAIN CURRENT PASSWORD, which keeps the old password working.
  3. End sessions that are already open

    Neon's docs say open sessions stay connected after a password reset, so don't assume the change cut anyone off. In Postgres, list connections with select pid, usename, client_addr, backend_start, application_name from pg_stat_activity; and end any you don't recognise with select pg_terminate_backend(pid); (you can end sessions of your own role; superuser sessions need a superuser). On Neon you can also restart the compute to drop them all.
  4. Limit who can connect

    A leaked password is much less useful if the database only accepts connections from your servers. Supabase: Network Restrictions on the Database Settings page limits which IP ranges can reach Postgres and the pooler (it doesn't affect the Data API, Auth or Storage, so supabase-js keeps working). MongoDB Atlas: remove 0.0.0.0/0 from IP Access List; Atlas warns that it allows access from anywhere. Your own server: firewall the database port and allow only your app's hosts in pg_hba.conf or MySQL's account host part.
  5. Check what was read or changed

    Look for tables, rows, users, roles, functions or triggers you didn't create, and compare row counts with a recent backup. On Postgres, check which roles exist (\du in psql). On Atlas, the project's Activity Feed records database user and IP access list changes. If the user could read personal data, such as emails, password hashes or payment details, treat it as a possible data breach: rotate any API keys or secrets stored in the database, and check what your local law requires you to tell your users.
  6. Keep the URL on the server

    A browser can't use a database URL safely, so it should never be in a VITE_, NEXT_PUBLIC_, REACT_APP_ or EXPO_PUBLIC_ variable or in code that runs in the page. Put database access behind server code (an API route, a Server Action, a Supabase Edge Function, a Cloudflare Worker) that reads DATABASE_URL from a server-only environment variable and checks who the user is. Give the app its own database user with only the rights it needs, not the owner. Then deploy and run the check again: old builds can stay in caches, which is why the password change comes first.

Or ask your AI tool to do it

Paste this into Lovable, Bolt, Cursor, Claude Code or whichever tool built your app. Review what it changes before you deploy.

My website's frontend JavaScript contains a database connection string with a password (postgres://, postgresql://, mysql://, mongodb:// or mongodb+srv://). Find every place the connection string or its password is defined or read, including .env files and any VITE_, NEXT_PUBLIC_, REACT_APP_ or EXPO_PUBLIC_ variable, and every file that imports a database client (pg, postgres, @neondatabase/serverless, mysql2, mongodb, mongoose, Prisma, Drizzle) in code that runs in the browser. Move all database access into server-side code (API routes, server actions or serverless functions) that reads DATABASE_URL from a server-only environment variable, requires a logged-in user, checks that the user may access the rows involved, validates input, uses parameterized queries and returns only the fields the page needs. Make sure no database client or connection string is included in the client bundle. List the endpoints you created and the minimum database permissions the server needs, so I can create a dedicated database user. Finally, remind me to reset the database password, end existing sessions, and restrict which IP addresses can connect.

How this happens

Usually a database call that ended up on the wrong side. Database drivers want a URL, and an AI coding tool asked to "load the products from the database" in a component, or to fix an undefined DATABASE_URL in the browser, will rename it to VITE_DATABASE_URL or NEXT_PUBLIC_DATABASE_URL so the error goes away. Serverless drivers that work over HTTP make this easy to miss: Neon's driver runs in a browser, and its docs say it prints a warning there because running SQL from client-side code can expose your database to misuse. Shared config files are the other route: a db.ts imported by both server and client code pulls the URL into the bundle.

Check that it's really fixed

After you deploy, run the free check. It reads your live site the way an attacker would and tells you if any secret key is still visible.

Topic check: Exposed API key checker

Find the other leaks before someone else does

The free check reads your home page and its scripts. The website security report goes through up to 30 pages and 40 JavaScript files, plus .env and .git files, security headers, cookies and CORS, domain and email records, and libraries with known vulnerabilities. Every finding comes with the fix for your host and a prompt for your AI tool.

$19 once, including 20 runs over 30 days so you can fix things and check again.

Get the report, $19 See an example report

Example report header: a score out of 100, findings by severity, Download PDF and Email me this report.

Questions

Is it enough to remove the URL from my code?

No. Old copies of your JavaScript stay in browser caches, CDN caches and web archives, and the password keeps working until you change it. Change the password first, then deploy the clean code.

My database only has a few test rows. Does it matter?

Yes, if it's the database your live app uses. Whoever has the URL can also create tables, functions or users that stay after you clean up, and on usage-billed hosts their heavy queries land on your bill. Change the password, then check for objects you didn't create.

Is it different from the Supabase anon key?

Very. The anon or publishable key is meant to be in the browser and only reaches Supabase's APIs, where Row Level Security applies. A postgres:// URL with the database password logs in to Postgres itself, usually as a role that owns the tables or bypasses RLS. If your Supabase app only needs supabase-js in the browser, it doesn't need the database URL there at all.

Can I make the database URL safe to use in the browser?

Not with a password in it. Anything your page can read, a visitor can read. Use your platform's browser-safe API instead (for example supabase-js with RLS), or your own server endpoints.

Does your check connect to my database?

No. The free check is passive: it finds postgres://, postgresql://, mysql://, mongodb:// and mongodb+srv:// URLs that contain a password in your page and its JavaScript, shows them cut short, and never connects with them. Only your database host can tell you who connected.

Sources

Related guides