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

theUnforgiven's avatar

Can't run php artisan locally

I get the following error when trying to run php artisan locally.

  [PDOException]
  SQLSTATE[HY000] [2002] No such file or directory

My .env file looks like:

APP_ENV=local
APP_DEBUG=true
APP_KEY=9SE5IlZhORj6Gk2OTS5jXZRprN4oLqJc

DB_HOST=localhost
DB_DATABASE=charity
DB_USERNAME=homestead
DB_PASSWORD=secret

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

Works find when inside VM (homestead) I don't understand how this could have just stopped working.

0 likes
5 replies
bashy's avatar
bashy
Best Answer
Level 65

Change DB_HOST to this

DB_HOST=192.168.10.10
1 like
theUnforgiven's avatar

That works, but has it changed? It was working yesterday, and doing composer update was providing same error.

bashy's avatar

No but localhost will resolve to your local machine and not the Homestead VM. Depends how you had that setup before. Maybe you pointed localhost to 192.168.10.10?

1 like
theUnforgiven's avatar

@bashy Dunno, no not done anything any different, the only thing I can think of, I have another dev working on this and he did composer update inside his VM rather than local and that has then cocked everything up for some reason & can't find where the issue would likely be if thats the case.

bashy's avatar

They changed the DB_HOST value? Not sure but it shouldn't normally work outside the VM when it's set to localhost.

Please or to participate in this conversation.