Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

munyamakudzai095's avatar

Server(cPanel) .env file changing its values back to default

on the server my laravel app is not working fine for a while but then later the .env contents changes back to the default values. what could be the cause of this?

0 likes
5 replies
Snapey's avatar

where could it be getting 'default' values from?

munyamakudzai095's avatar

@Snapey I mean the values that comes with the .env by default

APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1

VITE_APP_NAME="${APP_NAME}"
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

if i replace those value for example of those for mail and database, after a while the values changes back.

hupp's avatar

@munyamakudzai095 There would be many reason that can happen. Checklist following:

  • Check Auto Backup/Restore is enabled.
  • Check GIt is init & .env file is in .gitignore & you are not making changes on GIt.
  • Incorrect File Permissions : Ensure that the .env file has the correct permissions set. It should ideally be readable and writable by the server process but not accessible to the public. Improper permissions could result in the file being modified or replaced.

Let me know your feedback after verified all.

hupp's avatar
hupp
Best Answer
Level 11

@munyamakudzai095 CI/CD Configuration: Your CI/CD pipeline might have specific build or deployment steps that overwrite the .env file with default values. Check your CI/CD configuration files (e.g., YAML files) to see if there are any explicit commands or scripts modifying the .env file.

Please or to participate in this conversation.