Lando has trouble accessing a URL from a non-Lando app on my system
Asked Answered
I

1

6

My company has software that runs within Docker on my system, but is not using Lando. This software is serving some data via the URL: http://local.relay.cool:8081/clicks-bff/api/ads/

I can hit this URL in an anonymous browser, cURL it from the terminal, and load it via Postman and it returns the expected data.

I'm running Lando with the Wordpress recipe and I'm developing a plugin. This plugin can hit external URLs and retrieve data, I've tried with several different ones just to confirm.

However when Lando attempts to hit the URL listed above I get a WP_Error:

object(WP_Error)#1269 (2) { ["errors"]=> array(1) { ["http_request_failed"]=> array(1) { [0]=> string(58) "cURL error 28: Resolving timed out after 5514 milliseconds" } } ["error_data"]=> array(0) { } }

Here's the .lando.yaml config block:

name: my app name
recipe: wordpress
config:
  webroot: wordpress

Is there some configuration option that I'm missing to allow Lando access to another URL on my machine?

Imprudent answered 16/7, 2020 at 22:3 Comment(4)
Can you check what address that curl in Lando is trying to reach? It seems DNS cannot resolve the name.Hayton
Try replacing local.relay.cool with IP address of your host but don't use localhost or 127.0.0.1. Use host's IP in the local network.Hayton
What is your lando version?Chambertin
You can install the Query Monitor plugin and check the status of the HTTP API Calls in the admin page where the error is displayed. en-ca.wordpress.org/plugins/query-monitorChambertin
S
1

From your question, it sounds like the URL you're trying to access is running on a non-Lando docker container on your machine.

This means routing from your Lando instance to the service will be a bit different that usual. You should be able to accomplish this the same way you would access localhost endpoints. As explained in this Lando issue on GitHub, you must use the $LANDO_HOST_IP environment variable to route to local services.

Since your containers are all running inside of a light hyper-v instance you'll need to know the hostname or IP of the host machine. Generally we set $LANDO_HOST_IP to your computer . . .

So try something like this (assuming you're using PHP's curl):

curl_init('http://' . $_ENV["LANDO_HOST_IP"] . ':8081/clicks-bff/api/ads/');
Seko answered 17/12, 2020 at 1:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.