Skip to content

Serving sites

Sites are served at http://<name>.test. To use a different domain, run valet domain <domain>, for example valet domain wip. Avoid local, which belongs to mDNS: Valet won’t delegate local or localhost and falls back to /etc/hosts entries for them.

valet park registers a directory. Every folder inside it becomes a site named after the folder:

Terminal window
cd ~/sites
valet park

Now ~/sites/blog is served at http://blog.test, ~/sites/shop at http://shop.test, and so on. Pass a path to park another directory without changing into it: valet park ~/work.

On systems where Valet uses /etc/hosts for name resolution, run valet restart hosts after creating a new project folder, so its name resolves. See DNS.

Command Effect
valet paths List the parked directories.
valet forget [path] Stop serving a parked directory.

To serve one project without parking its parent directory, link it:

Terminal window
cd ~/projects/api
valet link # http://api.test
valet link backend # http://backend.test
Command Effect
valet links List all links.
valet unlink [name] Remove a link.

Valet creates its own certificate authority and adds it to your system’s trust store and to the NSS databases browsers use. To serve a site over HTTPS with HTTP/2:

Terminal window
valet secure blog # https://blog.test
valet unsecure blog # back to plain HTTP
valet secured # list secured sites

To give a Node app, a Docker container or anything else listening on a local port a Valet domain:

Terminal window
valet proxy app http://localhost:3000 --secure # https://app.test
valet proxies # list proxies
valet unproxy app
Command Effect
valet open [domain] Open the current (or given) site in your browser.
valet which Show which driver serves the current directory.
valet share Share the current site on a public URL through ngrok.
valet fetch-share-url Print the URL of the running ngrok tunnel.
valet ngrok-auth <token> Store your ngrok auth token. Sharing needs an ngrok account.

Valet’s Nginx listens on all network interfaces, so other devices on your network can reach your sites through nip.io, a public DNS service that resolves a name containing an IP address to that address. Find your machine’s LAN address with ip -4 addr, then open the site at http://<site>.<address>.nip.io from another device:

http://blog.192.168.1.20.nip.io

Valet recognises the .nip.io suffix and serves the blog site. This needs:

  • the other device to reach nip.io’s DNS (or your router to pass such lookups on),
  • your firewall to allow incoming connections on port 80.

This serves sites over plain HTTP, secured ones included, because Valet’s certificates are only for .test names and only your machine trusts them. For an HTTPS link, use valet share.

Valet listens on ports 80 and 443. To change them:

Terminal window
valet port 8080 # HTTP
valet port 8443 --https # HTTPS

Where Valet can delegate its domain through systemd-resolved, any subdomain of a site works too: api.blog.test reaches blog.test. Otherwise only the exact site names resolve. See DNS for when each applies.