Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

232
Views
HTTP request from a Laravel app on one Apache virtual host to a Lumen app on sibling virtual hosts: MySQL Access denied for user 'root'@'localhost'

I have a very strange problem with Laravel and Lumen apps on WAMP virtual hosts. In short the problem is the DB credentials from Laravel app overwrite these on Lument app while in an HTTP request. This causes the Lumen app to throw MySQL Access denied error.

My Setup

I am under WAMP on my local dev machine, two virtual hosts established. One for Laravel app (say laravel.localhost, web application), another for Lumen app (lumen.localhost, web service, API). Both apps are served via Apache virtual hosts from different hard disk folders.

Both apps have different .env configs. On Laravel app the DB config is not configured (a defaut one is kept, not using a DB). On Lumen app the database access to specific DB configured. Both use default DB config part:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306

but of course different DB names and credentials.

Access denied for user 'root'@'localhost'

The issue comes as soon as from browser (!) or from Postman (!) I make an HTTP request from laravel.localhost to lumen.localhost. I receive a request on Lumen app side and I connect to DB. Then Access denied for user 'root'@'localhost' SQL error comes.

If I inspect the database connection on the Lumen app side (config('database.connections.mysql')), it shows the DB credentials from Laravel app side which is a big surprise for me.

Of course, as Lumen app has different DB credentials, the Laravel app's DB credentials cause the Access denied error.

Another side of this effect is if I put Lumen app's DB credentials into Laravel app .env the HTTP request goes with no errors.

Strange Behaviour

This all makes me think that these both apps somehow share the same PHP or PDO or whatever environment the Larevel DB config is kept in. And this behaviour is very strange.

On the contrary, if I make the same HTTP requests from my PHPUnit tests from Laravel app to Lumen app there is no issue.

Clearing Laravel caches does not help. The Laravel app DB credentials are not cached. I may change them before each request and they leak into the Lumen app's side "with" the request.

Anybody can help?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!