valet: Valet secure does not work

OS: macOS Sierra 10.12.1
Valet version: 1.1.22

Hello,

When I execute the command valet secure, a message says that the site has been secured with a fresh TLS certificate (as it should).

If I try to access (http and https) the website, it gives me a browser 404 (so Valet does not seem to run). If I unsecure the site however, it works fine.

What could be the problem? I tried to completely remove Valet (including ~/.valet). Still no luck 😕

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 47 (18 by maintainers)

Commits related to this issue

Most upvoted comments

I found a gist by Adam Wathan about Troubleshooting Valet on Sierra that helped me with this issue:

  1. Connection refused to https://mysite.dev
  2. Checked the Caddy start log at /tmp/com.laravel.valetServer.err
  3. Found this error: open /Users/myusername/.valet/Log/access.log: no such file or directory
  4. Discovered that the /Users/myusername/.valet/Log directory did not exist.
  5. Created the directory
  6. Ran CLI: touch /Users/myusername/.valet/Log/access.log
  7. Ran CLI: valet restart
  8. Re-checked the site at https://mysite.dev. Success!

@ahmedash95 did you have Nginx already installed before installing Valet?

Try valet stop && brew uninstall --forge nginx, then re-run valet install to make sure nginx is installed with the correct flags.

Had the same problem and it turned out I needed to update to the latest version of Laravel Valet. I was using 2.0.3 and now updated to 2.0.4 which solved my problem.

  • valet stop
  • valet uninstall
  • composer global require laravel/valet
  • valet install
  • valet restart

Hope this helps!

When use valet secure,nginx needs ngx_http_v2_module.Try nginx -t you will get the info. In mac,valet stop && brew uninstall --forge nginx and brew install nginx --with-http2 now it works. the option --with-http2 activate the ngx_http_v2_module.

PS: Valet source

Nginx.php

function install() { $this->brew->ensureInstalled(‘nginx’, [‘–with-http2’]); //see this line $this->installConfiguration(); $this->installServer(); $this->installNginxDirectory(); }

Brew.php

function ensureInstalled($formula, $options = [], $taps = []) { if (! $this->installed($formula)) { $this->installOrFail($formula, $options, $taps); } }

function installed($formula) { return in_array($formula, explode(PHP_EOL, $this->cli->runAsUser('brew list | grep '.$formula))); }

So,if you installed the nginx without http2 before valet,valet secure will not work;

https://github.com/laravel/valet/blob/master/cli/Valet/Site.php#L239

just change /C=/ST=/O=/localityName=/commonName=*.%s/organizationalUnitName=/emailAddress=/ to /commonName=*.%s/ solved the problem

Try going into the project directory and running valet secure without the domain and see if that works.

I tried @mitoop solution to remove nginx and re-install with the --with-http2 flag. That didn’t work as it gave me an unknown flag warning during the install (in the console logs) and continued to install nginx which failed to fix the bug.

I then checked the available flags using brew options nginx to see there was no —with-http2 flag. So I did a brew uninstall nginx and then did a brew install nginx-full --with-http2 (this had the necessary flag and you can check using brew options nginx-full). Once installed, I did a valet install, cd’ed into the project folder and did a valet secure and valet open. The bug was fixed and my project opened properly with https.

Sounds like a certificate file didn’t get generated or somehow got deleted.

Try running the following which will force Valet to regenerate all certs:

valet domain blah
valet domain dev

@blyleven well i’m using 2.0.4