Lando Proxy Fails with ERROR bind: address already in use

I wrote an article last year about setting up a host machine for local PHP development that has hopefully helped folks get up and running! I’ve recently run into a frustrating issue however, and I wanted to take a few minutes to talk about it and the solution.

I noticed after updating to Docker Desktop 3.3.x and Lando 3.1.4 that I started losing my “pretty” URL for my Lando appserver. On the GovCon site, it looks something like this:

   ___                      __        __        __     __        ______
  / _ )___  ___  __ _  ___ / /  ___ _/ /_____ _/ /__ _/ /_____ _/ / / /
 / _  / _ \/ _ \/  ' \(_-</ _ \/ _ `/  '_/ _ `/ / _ `/  '_/ _ `/_/_/_/ 
/____/\___/\___/_/_/_/___/_//_/\_,_/_/\_\\_,_/_/\_,_/_/\_\\_,_(_|_|_)  
                                                                       

Your app has started up correctly.
Here are some vitals:

 NAME            drupalgovcon                                   
 LOCATION        /Users/mike.madison/git/d4g/Drupal-GovCon-2017 
 SERVICES        appserver, database                            
 APPSERVER URLS  https://localhost:58170                        
                 http://localhost:58171                         
                 http://drupalgovcon.lndo.site/                 
                 https://drupalgovcon.lndo.site/     

Except, after the upgrade my last two URLs (the once I usually use to connect to the container) are red AND frequently on lando start / lando restart / lando rebuild I get errors like…

ERROR: for 0845ebb254bb_landoproxyhyperion5000gandalfedition_proxy_1  Cannot start service proxy: driver failed programming external connectivity on endpoint landoproxyhyperion5000gandalfedition_proxy_1 (e6946583ad5ccd998b64692acfea63901adc4681df9a9bb28c4f1b12ae721a41): Error starting userland proxy: listen tcp4 127.0.0.1:443: bind: address already in use
ERROR: for proxy  Cannot start service proxy: driver failed programming external connectivity on endpoint landoproxyhyperion5000gandalfedition_proxy_1 (e6946583ad5ccd998b64692acfea63901adc4681df9a9bb28c4f1b12ae721a41): Error starting userland proxy: listen tcp4 127.0.0.1:443: bind: address already in use
ERROR: Encountered errors while bringing up the project.
ERROR ==>  message=, stack=Error
    at /snapshot/lando/build/cli/lib/shell.js
From previous event:
    at Shell.sh (/snapshot/lando/build/cli/lib/shell.js)
    at Object.dc (/snapshot/lando/build/cli/lib/bootstrap.js)
    at compose (/snapshot/lando/build/cli/lib/bootstrap.js)
    at /snapshot/lando/build/cli/lib/router.js
    at /snapshot/lando/build/cli/lib/router.js
    at processImmediate (internal/timers.js:456:21)
From previous event:
    at retryEach (/snapshot/lando/build/cli/lib/router.js)
    at Object.start (/snapshot/lando/build/cli/lib/router.js)
    at /snapshot/lando/build/cli/lib/engine.js
    at /snapshot/lando/build/cli/lib/router.js
From previous event:
    at Object.eventWrapper (/snapshot/lando/build/cli/lib/router.js)
    at Engine.engineCmd (/snapshot/lando/build/cli/lib/engine.js)
    at Engine.start (/snapshot/lando/build/cli/lib/engine.js)
    at /snapshot/lando/build/cli/plugins/lando-proxy/app.js
From previous event:
    at AsyncEvents.<anonymous> (/snapshot/lando/build/cli/plugins/lando-proxy/app.js)
    at AsyncEvents.handle (/snapshot/lando/build/cli/lib/events.js)
    at /snapshot/lando/build/cli/lib/events.js
    at processImmediate (internal/timers.js:456:21)
From previous event:
    at AsyncEvents.emit (/snapshot/lando/build/cli/lib/events.js)
From previous event:
    at App.start (/snapshot/lando/build/cli/lib/app.js)
    at /snapshot/lando/build/cli/lib/app.js
From previous event:
    at App.rebuild (/snapshot/lando/build/cli/lib/app.js)
    at Object.run (/snapshot/lando/build/cli/plugins/lando-core/tasks/rebuild.js)
From previous event:
    at /snapshot/lando/build/cli/lib/cli.js
From previous event:
    at Object.handler (/snapshot/lando/build/cli/lib/cli.js)
    at Object.runCommand (/snapshot/lando/build/cli/node_modules/yargs/lib/command.js:238:44)
    at Object.parseArgs [as _parseArgs] (/snapshot/lando/build/cli/node_modules/yargs/yargs.js:1063:30)
    at Function.get [as argv] (/snapshot/lando/build/cli/node_modules/yargs/yargs.js:1004:21)
    at Cli.init (/snapshot/lando/build/cli/lib/cli.js)
    at Cli.run (/snapshot/lando/build/cli/lib/cli.js)
    at Object.<anonymous> (/snapshot/lando/build/cli/bin/lando.js)
    at Module._compile (pkg/prelude/bootstrap.js:1433:22)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1156:10)
    at Module.load (internal/modules/cjs/loader.js:984:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Function.runMain (pkg/prelude/bootstrap.js:1488:12)
    at internal/main/run_main_module.js:17:47, __stackCleaned__=true
Docker Compose is now in the Docker CLI, try `docker compose up`

This has been driving me insane… I know what the problem is but I haven’t been able to figure out how to fix it. Not until today, anyway. Let’s talk about the cause and the solution!

Root Cause Analysis

I spent a lot of time chasing my tail on this one, to be honest. I was really sure that something in the Docker Desktop or Lando update caused the problem, but I couldn’t for the life of me figure out what. I tried downgrading, reinstalling, etc. and nothing fixed the issue.

I was able to zero in on a particular part of the error, specifically: Error starting userland proxy: listen tcp4 127.0.0.1:443: bind: address already in use. As is so often the case with “big ass error output” the pertinent info is a pretty small part of the output. I tried to pin down what, precisely, what using that IP address but to no avail.

What was even more strange… was that this used to work just fine. What changed?

So in that article I referenced from last year, a big thing I highlight is that there is reason to use multiple local containerization strategies in an agency setting. Some projects might use one, others might use another. No big deal! BUT something I overlooked in my updating of Lando and Docker Desktop… was that I also installed Docksal for a project (that was what caused me to update Docker Desktop in the first place!

This ultimately lead me to https://github.com/docksal/docksal/issues/387 which got me my solution.

Solution

In this case, the solution was so simple. Just stop Docksal.

fin system stop
Stopping all running Docksal projects...
Stopping Docksal system services...
Password:
Clearing DNS cache...
Removing NFS exports...
Writing and applying /etc/exports...
Configuring network settings...

Then rebuild your Lando container.

This is a great reminder that sometimes things don’t work together. And in this case, both Lando and Docksal continued to work great on my system in parallel, the only issue was that I couldn’t get my Lando proxies to work while Docksal was running.

Related Content