# Port-forwarding with Lima-VM and Ray app

**URL:** https://discourse.roots.io/t/port-forwarding-with-lima-vm-and-ray-app/25167
**Category:** trellis
**Created:** 2023-04-14T23:32:13Z
**Posts:** 3

## Post 1 by @needle — 2023-04-14T23:32:13Z

I recently made the switch from Vagrant to Lima-VM with my Trellis setup. With Vagrant, I was using the [Ray app](https://spatie.be/docs/ray/v1/introduction) (along with the [WordPress-specific plugin](https://spatie.be/docs/ray/v1/installation-in-your-project/wordpress)) for debugging PHP, and it worked well. With Lima, I can’t get it to work.

Now if I add some Ray logging in my code, e.g. in `functions.php` I have `ray('hello world');` I should see **‘hello world’** echoed in the app, but nothing shows up.

My limited understanding is that by default the Ray package communicates with the Ray desktop app via port `23517` in the VM.

Based off of [this reference](https://github.com/lima-vm/lima/blob/df25c45939cebacb1a479f1d4ac4f44491e86871/pkg/limayaml/default.yaml#L144) in the Lima repo, I tried creating a file at `trellis/.trellis/cli.yml` with the following:

```
portForwards:
  - guestPort: 23517
```

But that doesn’t seem to have had any effect; the Ray app still isn’t receiving data.

Currently my ray.php config file looks like this

```
<?php
return [
    /*
     * Whether data should be sent to Ray.
     */
    'enable' => true,

    /*
     * The host used to communicate with the Ray app.
     */
    'host' => '127.0.0.1',

    /*
     * The port number used to communicate with the Ray app.
     */
    'port' => 23517,

    /*
     * Absolute base path for your sites or projects in Homestead, Vagrant, Docker, or another remote development server.
     */
    'remote_path' => null,

    /*
     * Absolute base path for your sites or projects on your local computer where your IDE or code editor is running on.
     */
    'local_path' => null,

    /*
     * When this setting is enabled, the package will not try to format values sent to Ray.
     */
    'always_send_raw_values' => false,
];
```

With Vagrant I had the `'host' => '10.0.2.2'` but I changed it to try and get it working with Lima.

Wondering what is the proper way to forward a specific port in the Lima guest so that messages can be received by an external host app?

---

## Post 2 by @talss89 — 2023-04-15T09:36:47Z

Hi Sam ,

I’ll prefix this by saying I don’t use Ray (although, looks v. interesting), so my understanding is limited too, but…

> [@needle](#):
>
> My limited understanding is that by default the Ray package communicates with the Ray desktop app via port `23517` in the VM.

I think this is the wrong way around. Ray app seems to open port 23517 on the 0.0.0.0 interface(s) where the app is running. This will be your host machine. Your `portForwards` config seems to be forwarding guest port 23517 to the host - we need the inverse.

Why not set the `'host' => '127.0.0.1'` line to the Lima host interface? Lima host should be accessible via `host.lima.internal`

---

## Post 3 by @needle — 2023-04-17T17:26:33Z

Thank you @talss89 , you are 100% correct!

I was misunderstanding how Ray works. There wasn’t an issue with ports - just changing the `host` setting from `'host => '127.0.0.1'` to `'host' => 'host.lima.internal'` was enough to get Ray working with Lima (in fact I had made a similar change when Ray was previously referencing Vagrant as host).
