Is Your .env File Public? Bots Are Requesting /.env on Your Site Right Now
Automated bots request /.env and /.git/config on public sites all day. How a .env file ends up downloadable, how to check yours in one command, and what to do if it is.
Updated 2026-11-04
Why bots keep asking for /.env
A .env file holds the secrets an app needs: database URLs, API keys, payment keys. If one is ever served from the root of a website, anyone who asks for /.env gets every secret in it at once.
Because that payoff is so big, automated scanners request /.env, /.env.local, and /.git/config on huge numbers of public sites, over and over. If you look at a web server's access logs you will usually see these requests from strangers within days of going live. You do not have to be famous to be checked.
How a .env file ends up public
- The whole project folder was uploaded to static hosting or a web server, dotfiles included
- The .env file sits in a folder that is served as-is, like public/ in Vite or Next.js
- A Docker image copies the full project into the folder the web server serves
- A server config (nginx, Apache) serves every file in the folder and does not block dotfiles
- The .git folder was deployed too, which can let someone rebuild your code and its history
Check your own site in one command
Run these against your live domain. A safe site returns 404 or 403, or returns your normal HTML page. If you see lines that look like NAME=value, the file is public.
curl -i https://your-app.example/.env curl -i https://your-app.example/.env.local curl -i https://your-app.example/.git/config
If it was public, do this
Removing the file stops new leaks, but anything already in it should be treated as stolen.
- Rotate every secret that was in the file, starting with payment, database, and cloud keys.
- Delete the file from the deployed folder and redeploy.
- Block dotfiles in your server config so it cannot happen again (for nginx: location ~ /\.(?!well-known) { deny all; }, which still allows /.well-known for HTTPS certificates).
- Make sure .env is listed in .gitignore and in any .dockerignore.
- Check provider usage and billing pages for activity you did not cause.
A prompt you can paste into your coding agent
Paste this into Cursor, Lovable, or Claude:
Check how this project is built and deployed. Make sure no .env file, .git folder, or other dotfile can end up in the folder that is served to the public. Add .env* to .gitignore and .dockerignore, and if there is a web server config, add a rule that denies requests for any path starting with a dot.
Check your live app for free
Freedom Check's free scan requests /.env, /.env.local, /.git/config, and /.git/HEAD on your site, exactly like those bots do. It only flags a file when the response is not an HTML page and looks like the real thing (for .env, at least two NAME=value lines). The report lists variable names, never the values. It also flags public JavaScript source maps.
The free scan shows how many issues turned up and explains the most serious one with a fix prompt. The full report is $19 one time, or $29/month for unlimited.
Run a free scan →See pricing