valet-linux: Bug: Lost network connection after running valet install

Basic info

Distro (Name and version) PHP Version Valet version
Ex: Ubuntu 22.04 8.1.2 Latest
  • [x]I’ve checked the issue queue and could not find anything similar to my bug.
  • I’m on the latest version of valet-linux (valet --version): 2.2.32
  • I’ve run valet fix and valet install after updating and before submitting my issue/feature.

What is the problem? After running valet install for a few seconds, the network connection is lost (the network icon shows an exclamation mark)

What was supposed to happen? Lost Internet connection

What actually happened? Network icon with exclamation mark and cannot network access

How to reproduce this?

  • Install new Ubuntu 22.04
  • Install Composer, Install Valet
  • Run valet install and lost internet.

I have reinstalled Ubuntu and tried to install Valet 3 times but still get the same problem

What is the solution? N/A

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 6
  • Comments: 28

Most upvoted comments

@datlechin, I had the same problem as the one you described (see my first comment on this issue) and found a solution and I’m going to share the steps with you in the hope that this would help.

TL;DR

  1. run echo "nameserver 8.8.8.8" >> /opt/valet-linux/custom-nameservers (I don’t remember if you need to restart something at this point)
  2. open /etc/default/dnsmasq and add the line DNSMASQ_EXCEPT=lo or un-comment it if you find it (I found it in the last line of the file on a fresh install) and restart dnsmasq

The details I actually went through two major problems :

First problem

Whenever, I installed valet, I lost network access and when I manage to configure my internet connection back, I override /etc/resolv.conf and cannot access my web applications served by Valet.

WHY ? (according to my very limited understanding) Because, I need my resolv.conf to check the nameserver 8.8.8.8 for my internet connection to work (I don’t know if everybody has this problem or just me) and by using valet’s resolv.conf it doesn’t do that by default

Solution to the first problem

I have to add the line nameserver 8.8.8.8 to some file that will always be checked by valet’s resolv.conf file (which is /op/valet-linux/valet-dns) and that file is /opt/valet-linux/custom-nameservers so adding this line there fixed this issue for me

Second problem

At this point, I was able to access both my network connection and my valet projects at the same time but for some very strange and unknown reason, after minutes of use and/or after each reboot, everything stops working, until I run valet install and restart my network manager (I described it in more details in my first comment)

WHY ? (according to my very limited understanding) There is some bug with dnsmasq that is way beyond my understanding (I read about it here and I even got my solution from there)

It’s worth mentioning at this point that when I ran service dnsmasq status, one of the lines I gor was no servers found in /opt/valet-linux/dns-servers, will retry and that error (or warning) line disappeared after the solution I described below

Solution to the second problem

I have to tell dnsmasq to not use my local machine as a dns resolver by adding the line DNSMASQ_EXCEPT=lo to the file /etc/default/dnsmasq (lo: the loopback interface) and restart the dnsmasq service


I hope this helps you solve your problem, if so please let me know so that one of us can add it to the docs as a potential solution for a potential problem)

This isn’t fixed as far as i can see. ass mentioned by @Alecaddd there hasn’t been any code changes to stop this from happening, just some work arounds which may or may not work.

Please could this be reopened until there is a merge for the fixes so we can keep up to date.

Kind Regards, Mike

I have the same issue :

My conf now is the following :

  • I ran valet install (this generates the /opt/valet-linux/resolv.conf file and makes /etc/resolv.conf point to it)
  • I added a file /opt/valet-linux/custom-nameservers with the lines nameserver 8.8.8.8 and nameserver 8.8.4.4 inspired by old issues of this repo (that I cannot find right now)

The problem :

Every few hours, for an unknown reason (that’s where the fix should happen), valet (or some other process ?!) rewrites the file /opt/valet-linux/resolv.conf to contain only one line nameserver 127.0.0.1 (that what causes the loss of Network connection) My temporary fix is to :

  1. re-run valet install
  2. restart my Network connection (by turning it off then on again from the top right menu)

It works for a few hours before causing the same problem

I am not sure but I think rebooting also causes the same issue.

I hope this helps identify the root of the problem

I’ll take a look when I find some spare time

Alessandro @.***> schrieb am So., 26. Juni 2022, 18:33:

@cpriego https://github.com/cpriego There seem to be a couple of places in the last release (2.2.32) where things are causing issues with the latest Ubuntu 22.04 and PHP 8.

(Most likely unrelated) Little nit with an extra return that will never be reached: https://github.com/cpriego/valet-linux/blob/f1264e29fcd89ec34c40a5eb08cb6ed603d25022/cli/Valet/PhpFpm.php#L246-L248

It seems to be that moving the installation of the configuration after ngxin, phpfpm, and dnsmasq installation is what caused the problem: https://github.com/cpriego/valet-linux/blob/f1264e29fcd89ec34c40a5eb08cb6ed603d25022/cli/valet.php#L40

— Reply to this email directly, view it on GitHub https://github.com/cpriego/valet-linux/issues/368#issuecomment-1166581068, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFHV64TAHC3OMXLXKV4SRLVRCAZNANCNFSM5VIDMNRQ . You are receiving this because you were mentioned.Message ID: @.***>

I have the same problem after upgrading to Ubuntu 22.04. Lost connection. And valet-linux doesn’t serve my sites either. I had to uninstall valet-linux to get internet connection back.