Laradock Setup Snags – Dealing with Typical Setup Issues to run Laravel on Laradock

Setting up Laradock is pretty straightforward …. once you have done it all. As it the same for most things in life. Allow me to share the major snags I ran into setting it all up.

Installing Docker

Setting up Docker on your box is not hard. Not anymore with Docker native. It now runs with ease on my MBP and so should it be on your Windows box. So I will not get into that in great detail. With Docker natively up and running you can do the basic Laradock setup:

  • create project folder
  • add laravel directory
  • add laradock directory
  • Laradock .env app path check
  • Laravel .env edit for database details
  • hosts file –  add laravel.test to /etc/hosts
  • NGINX – /etc/nginx/sites/available/laravel.conf creation based on example and check

and a simple:

docker-compose up -d nginx mariadb redis workspace

will get you going with the necessary containers.

NB I will not go into installing git which you will be needing to clone Laravel and Laradock. But I assume you got that down already.

Port Conflicts

However if you were already running MAMP, XAMP or Laravel Valet with MariaDB you will have issues running the containers as ports will be occupied. Allow me to share a great command to see what is running on port 3306 and 443 for you to quickly figure this out:

lsof -n -i4TCP:3306 | grep LISTEN
lsof -n -i4TCP:443 | grep LISTEN

Using this command for these two ports I realized Laravel Valet was up and running so I did a:

valet stop

and to stop Homebrew’s MariaDB I did a:

brew services stop mariadb

Afterwards the ports 443 and 3306 were available.

Laradock running?

You will have Laradock running now. And the command:

docker-compose up -d nginx mariadb redis workspace

should work with port conflicts out of the way. And on localhost or with /etc/hosts tweaked you should be able to load something like this:

laradock on localhost

But you will see soon enough you are not out of the woods yet.

MySQL Connection Refused

So all happy with port conflicts dealt with and with all containers up and running you enter your Docker workspace box and run php artisan migrate:

docker-compose exec workspace bash
php artisan migrate

thinking it will just run…. Then you will get something like:

SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where 
table_schema = homestead and table_name = migrations)
SQLSTATE[HY000] [2002] Connection refused

This is because your Laravel .env is not grabbing the proper database host.

Laravel .env tweak

To deal with this issue make sure you use mysql for the host inside the laravel .env file:


And that the user, password and databases are added to the Laradock .env. Otherwise you will have to add them manually in MariaDB using the command line or a program like Sequel Pro. Once you have all that done you can access the database from your Docker workspace and run migrations:

root@fa3ff8144e8e:/var/www# php artisan migrate
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated: 2014_10_12_100000_create_password_resets_table

And when you access the database using Sequel Pro and as host with the earlier mentioned user and database credentials you will see the new tables inside the database:

Sequel Pro Laradock Database


Tagged in : Tagged in :
Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.