Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.env file is not loaded sometimes #756

Open
tysian opened this issue Jan 16, 2025 · 0 comments
Open

.env file is not loaded sometimes #756

tysian opened this issue Jan 16, 2025 · 0 comments
Labels

Comments

@tysian
Copy link

tysian commented Jan 16, 2025

Version

1.26.0

What did you expect to happen?

Read all env values from .env file.

What actually happens?

Environmental variables are not loaded from .env file and DB_HOST value fallbacks to localhost. "Error establishing a database connection" is thrown. Need to refresh a couple of times to open desired page. It happens like 33% times when navigating through the wp admin.

I've found a workaround by reverting this #598 PR.

Steps to reproduce

  1. Install Bedrock
  2. Add external db credentials in .env file
  3. Go to "create new post" admin page
  4. Refresh it a couple of times

System info

Windows 10 Professional
Laragon 5.0.0
Apache httpd 2.4.35 VC15
PHP 8.1.3
MySQL 8.0.33-25 (external database)

Log output

Error establishing a database connection
This either means that the username and password information in your wp-config.php file is incorrect or that contact with the database server at localhost could not be established. This could mean your host’s database server is down.

Are you sure you have the correct username and password?
Are you sure you have typed the correct hostname?
Are you sure the database server is running?
If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress support forums.

Please confirm this isn't a support request.

Yes

@tysian tysian added the bug label Jan 16, 2025
@tysian tysian changed the title phpdotenv library is not reading .env file sometimes .env file is not loaded sometimes Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant