How to stop Laravel’s Valet asking for password
Tags: php, laravel, webdev, programming
Published: 2021-02-09 10:45:35

---
title: How to stop Laravel’s Valet asking for password
published: true
description: In this article you will learn why Valet asks for a password after a clean installation and how to stop it from doing that.
tags: php,laravel,webdev,programming
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/0c6u7r1jk8sji1ezyx12.png
canonical_url: https://medium.com/@EeKayOnline/how-to-stop-laravels-valet-asking-for-password-a03694814c5b
---

If there is one aspect of Laravel that I like, it’s that it is accompanied by very nice tools.

Depending on how you like to develop you can even choose between different approaches and tools to develop with Laravel.

![Valet is part of the Laravel toolset](https://dev-to-uploads.s3.amazonaws.com/i/b4qlbe4na8wgusgu5fuq.png)

[Valet](https://laravel.com/docs/8.x/valet) is one of those tools. If you — like me — like to quickly setup your development environment, and test your work in progress asap, Valet helps you to setup test domains on your local machine very fast.

As Valet’s documentation explains:
> Valet is a Laravel development environment for macOS minimalists. Laravel Valet configures your Mac to always run [Nginx](https://www.nginx.com/) in the background when your machine starts. Then, using [DnsMasq](https://en.wikipedia.org/wiki/Dnsmasq), Valet proxies all requests on the *.test domain to point to sites installed on your local machine.

## What’s up with the password?

When you’ve developed in Laravel using Valet before, you will notice that once you reinstall Valet on a new machine (or clean install), it will start asking for a password.

After some research on Github, I found out why this is. 
As it appears, there are two factors causing the continuous password prompt:

* For security reasons, Valet prompts for the sudo password every time the command is used in a new terminal session

* The code previously searched two files. The code that would create two files in /etc/sudoers.d [was removed](https://github.com/laravel/valet/issues/446#issuecomment-333196825) from the sourcecode

Since Valet uses sudo rights for some actions it needs to take, it depends on getting sudo rights to fully function.

## How to prevent Valet from asking your password?

The answer is quite simple: you need Valet to trust your computer.

As you can find on the documentation page for Valet, the solution is revealed in [the “other commands” section](https://laravel.com/docs/8.x/valet#other-valet-commands):

![](https://cdn-images-1.medium.com/max/2572/1*628WeS4HP7Q1y1ngDO-k1g.png)

As the command states:
> Add sudoers files for Brew and Valet to allow Valet commands to be run without prompting for your password.

Whereas the sudo command allows non-root users to run commands that would normally require super user privileges, the sudoers file instructs the system how to handle the sudo command (source: [hostinger.com](https://www.hostinger.com/tutorials/sudo-and-the-sudoers-file/)).

So, by using the “valet trust” command, you will indicate that the current machine can be trusted, which results in sudoers adjustments that will give Valet sudo permissions to operate correctly and without asking for your password each and every time.

## To conclude

Please understand that the reason that you were prompted for the password in the first place, is because of increased security measures.

The security impact for using sudoers to give Valet sudo rights has also been discussed by the community on [this Github thread](https://github.com/laravel/valet/issues/446) concerning the issue.

Although using the trust command makes it easier to use valet without having to enter your password every time, always think about your machine setup, its connectivity to the internet and how this might affect your security at a realistic level.

Me personally, I’m happy to trust my device and am using Valet with a big smile once more.

Code Hard, Ship Harder 🔥

_This article is also published on [Medium](https://eekayonline.medium.com/how-to-stop-laravels-valet-asking-for-password-a03694814c5b)_