8

I have an app (sveltekit) running inside and would like to access it from other devices on my local network.

I can access it normally from the host machine on localhost:3000.

I want to access it somehow from another machine on the local network. Is this possible? Sveltekit cli has --host flag, which outputs the following:

$ svelte-kit dev --host

local:   http://localhost:3000
network: http://172.17.0.3:3000

How do I access that network url from a different device on the local network?

OS: Pop OS
VSCode: 1.63.0 
Docker: Latest stable version.

Docker Installed using repository. Running in rootless mode.

ambiguous58
  • 1,241
  • 1
  • 9
  • 18
  • My use case: I want to see my website on my actual physical phone while I'm developing. – ambiguous58 Jan 01 '22 at 00:27
  • when you start dev server with `-host` you are already given the IP address to your `local` network which you can use to connect from your phone, if your phone is connected over same wifi router. however, you may also need to expose your `port 3000` in your OS's firewall else no one can connect. – Yılmaz Durmaz Jan 01 '22 at 03:54
  • Does this answer your question? [Specify listening address 0.0.0.0 for forwarded port in VSCode Remote Containers](https://stackoverflow.com/questions/67983378/specify-listening-address-0-0-0-0-for-forwarded-port-in-vscode-remote-containers) – Chris Apr 24 '23 at 13:44
  • 1
    @Chris hi, yes this is the same link I'm referring to in the accepted answer below :) – ambiguous58 Apr 25 '23 at 19:33

1 Answers1

7

All that was needed was to change the following VSCode setting. By default it was set to "localhost". Setting it to "allInterfaces" grants access to other devices on the local network.

// settings.json

"remote.localPortHost": "allInterfaces"

Then, on another device connected to the same wifi network, use the following URL:

Format: <your-local-ip>:3000
Example: 192.168.1.105:3000

Note: In this scenario passing --host to the sveltekit cli is not required. VSCode seems to be handling that.

ambiguous58
  • 1,241
  • 1
  • 9
  • 18