Laravel Sail how to change local dev domain
Stefan Izdrail
Founder & Senior Architect · 2026-06-29
Simplifying Local Development with Laravel Sail and Custom Domains
Laravel Sail is an amazing tool that makes local development easier for developers by providing a Docker-based environment. However, sometimes you may want to change the default domain name from "localhost" to something more convenient or professional-looking for your project. This blog post aims to guide you through changing the local dev domain on Laravel Sail and improve your workflow while offering alternative solutions if necessary.Step 1: Configure your hosts file
First, you'll want to modify your Windows (C:\Windows\System32\drivers\etc\hosts) or Mac/Linux (~/.hosts) hosts file. This will allow the browser to recognize custom domain names when they are mapped to local IP addresses. Simply add a new line in this file stating:127.0.0.1 laravel.test
Where 'laravel.test' is your desired domain name for accessing the application locally. Save and close the file, and then open it again with administrative privileges to ensure the changes are saved correctly.
Step 2: Configure Laravel Sail
Now, you need to modify your.env file in your Laravel project's root directory. Add a new line:
APP_URL=http://laravel.test
This will set the desired domain name as your application's default URL. You can also use APP_URL=http://localhost for the standard localhost access.