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?

commadelimited
  • 5,656
  • 6
  • 41
  • 77
  • Can you check what address that curl in Lando is trying to reach? It seems DNS cannot resolve the name. – anemyte Dec 11 '20 at 06:23
  • 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. – anemyte Dec 11 '20 at 07:25
  • What is your lando version? – Ozgur Sar Dec 11 '20 at 13:40
  • 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. https://en-ca.wordpress.org/plugins/query-monitor/ – Ozgur Sar Dec 11 '20 at 13:48

1 Answers1

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/');
Nikolas Stevenson-Molnar
  • 4,235
  • 1
  • 22
  • 31