Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

225
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda