Skip to contentLockpick
How it worksPricingDocs

Read

  • BlogPlain answers to common security questions
  • GuidesStep by step fixes for common setups
  • Security checksEvery check we run, explained

Learn

  • Learn with PickTwo-minute lessons on how sites get attacked
  • Lockpick for ClaudeCheck sites from Claude and other assistants
  • GlossaryThe words we use, in plain words

Company

  • ChangelogWhat changed, newest first
  • StatusWhether scans are running right now
  • Security and trustHow we check and what we never do
Sign inCheck it
Blog

.env file publicly accessible, how it happens and how to fix it

By Mark KashefPublished October 8, 2026

If your .env file loads at a public address, every value in it is public. Remove it from the live site, then replace every secret it held. Attackers try common file names on every site they visit, like /backup.zip, /.env or /.git/.

How does it end up online?

Nearly always by being copied into a folder the host serves as-is.

How it happenedWhy it is public
The file sits in a Vite public folderVite serves everything in the public directory at the root path and copies it to the build output as-is.
The file sits in a Next.js public folderNext.js serves files inside public from the base URL /.
The whole project folder was uploaded to a plain web hostThe host serves every file it was given
A server serves the project folder instead of the build outputThe root of the project becomes the root of the site

Next.js notes that its default template adds all .env files to .gitignore, and says you almost never want to commit them. Keeping it out of the repository helps, but it does not stop a copy in a served folder.

Curious what your site shows from outside? The quick check is free and needs no account.

Check it

What to do, in order

  1. Delete the file from the live site, then ask whether anything in it needs replacing, because a leaked password needs changing, not just hiding.
  2. Replace every key and password the file held with the service that issued it.
  3. Fix the build so only the built site is uploaded, and keep settings files outside any served folder.
  4. Deploy, then check that the address no longer loads.

How to check

A Lockpick scan checks a short, careful list of common file names and never downloads more than it needs to confirm one is there. Atlas, our example app at atlas.example, is where to test this kind of mistake. Run a quick check on your published address to see what a stranger sees, then read how we check for what it covers. A check that does not find the file cannot prove no copy exists under another name, so keep secrets in your host's settings rather than in files next to the site.

Questions people ask

My .env file is in .gitignore. Can it still be public?

Yes. Ignoring it keeps it out of the repository, but a copy in a served folder or an uploaded project folder is still public.

I deleted the file from the server. Is that enough?

No. Anyone may already have the values, so replace every secret it held.

See what your site shows from outside

A quick check reads your homepage the way a visitor would and gives you a score. No account needed.

Check your site

Related pages

  • API keys in your JavaScript bundle, how they get there and what to do
  • How Lockpick checks a site, and what we never do
  • Replit app security checklist for a live app

Sources

  1. Files you forgot were public Lockpick docs, read on October 6, 2026
  2. How to use environment variables in Next.js Next.js docs, read on October 6, 2026
  3. public Folder Next.js docs, read on October 6, 2026
  4. Static Asset Handling Vite docs, read on October 6, 2026

About the author

Mark Kashef, Founder of Lockpick

I'm Mark, and I build Lockpick. I write these pages, and each one is checked against its sources before it goes live. The Updated date changes only when the page itself does.

Lockpick
PricingMethodologyDocsBlogGuidesSecurity checksLearn with PickSecurity and trustLockpick for ClaudeChangelogStatusFacts for AI assistants

Lockpick is a security scanner for vibe-coded apps. It checks what your live site exposes and what a GitHub repo or AI skill would do before you install it, then gives you a fix prompt for Lovable, Bolt, Replit, Cursor or Claude Code.

Lockpick assesses public pages you are authorized to test, and public GitHub code it never runs.

© 2026 LockpickTermsPrivacyContactSign in