Connecting to a Remote Pieces OS Instance
If Pieces OS is running on the same machine as VS Code, there should be no requirement to use this feature. Please verify these steps are required for your set up before following this guide. This custom URL is not the same thing as your Pieces Cloud custom url.
Through multiple user support tickets, we have noticed that many of our users are using the Pieces for Developers VS Code extension in a remote development environment.
This guide will walk you through how to connect to a remote Pieces OS instance using the Pieces for Developers VS Code extension.
This is currently only available for the Pieces for Developers VS Code extension. Functionality for the rest of the Pieces for Developers ecosystem is coming soon.
Windows Subsystem for Linux (WSL)β
Windows Subsystem for Linux (WSL) must be installed and configured on your machine
This integration should work out of the box with WSL. If you are having trouble connecting, please see the Troubleshooting section for steps on how to set up an inbound firewall rule.
VS Code Dev Containersβ
As of the 1.12.0 release of the extension, Dev Container environments should also work with no extra configuration required. Once again, if you have trouble connecting please see Troubleshooting.
Troubleshootingβ
Pieces OS is not connecting on WSLβ
For WSL users, if the connection does not work automatically, you can either enable 'mirrored' networking or set up an inbound firewall rule to allow the connection.
Mirrored networking is the simplest way to resolve WSL connection issues, it requires WSL >= 2.0.0 and Windows 11.
How to set up mirrored networking (recommended): source
- Locate your .wslconfig file located at (windows_user_profile)/.wslconfig i.e: 'C:\Users\caleb\.wslconfig'. If the .wslconfig file is not present, then create it at the specified path
- If there is not a section labeled '[wsl2]', create one.
- Add a line under the [wsl2] section that says: 'networkingMode=mirrored'
- By the end of these steps your .wslconfig file should look something like:
[wsl2]
networkingMode=mirrored
- Restart WSL by running
wsl --shutdown
andwsl
in a Windows command prompt
How to set up the firewall rule:
- Open Windows Firewall: Press
Win + R
, searchfirewall.cpl
, and press Enter. - In the left pane, click on
Advanced settings
to open the Windows Firewall with Advanced Security. - In the left pane, click on
Inbound Rules
. - On the right pane, click on
New Rule
. - Rule Type: Select
Port
and click Next. - Protocol and Ports: Choose
TCP
and specify port number1000
. Click Next. - Action: Select
Allow the connection
and click Next. - Profile: Choose Public, Private, and Domain for the profile.
- Name: Give the rule a name like
Local Devices on Port 1000
, and click Finish.
Pieces OS is not connecting on Dev Containersβ
For Dev Container users, if the connection does not work automatically, there are a couple of troubleshooting steps to take.
- You must ensure that Pieces OS is running before launching VS Code. Please try starting Pieces OS and then reloading your VS Code window. a. see this guide for how to reload your VS Code window
- Similarly to the WSL troubleshooting guide above, there may be a firewall that is blocking requests between machines on your LAN. Try setting up an inbound firewall rule on the machine running Pieces OS to resolve this. a. for Windows and macOS the rule should be placed on port 1000 b. on linux, the rule should be placed on port 5323
Use Casesβ
Prerequisitesβ
- 1 machine with Pieces OS installed
- 1 machine with the Pieces for Developers VS Code extension installed
Getting Startedβ
Using the Custom URL Feature to Access a Remote Pieces OS Instanceβ
- In the case that Pieces OS shares the same LAN with your remote VS Code instance, you should use the LAN IP address of your machine that is running Pieces OS.
- In the case that Pieces OS is not on the same LAN as your development environment ngrok, or a similar alternative like Tailscale, must be installed on the machine with Pieces OS. It must be known that doing this will expose your Pieces OS endpoints to the public and this should only be done as a last resort.
- The custom URL feature has no connection to your custom Pieces Cloud domain, attempting to use your custom Pieces Cloud domain i.e:
https://caleb.pieces.cloud
will result in the VS Code extension ceasing to function properly.
- LAN IP Address
- Static URL
- Generated URL
- Ensure that there is not a firewall in place that will block connection between two machines on your LAN.
- Locate your machine's LAN IP address a. If possible, you should also set up a DHCP IP reservation for your machine running Pieces OS so this IP address will not change in the future.
- Your custom URL will be:
a. Linux:
http://{'{LAN IP ADDRESS}'}:5323
b. macOS or Windows:http://{'{LAN IP ADDRESS}'}:1000
- Install ngrok on the machine with Pieces OS if it isnβt already
- Run the following command on your machineβs terminal:
a. (windows and macos)
ngrok http --domain=STATIC_URL_HERE 1000
b. (linux)ngrok http --domain=STATIC_URL_HERE 5323
- Copy the forwarding URL it generates to use in the next step
- Install ngrok on the machine with Pieces OS if it isnβt already
- Run the following command on your machineβs terminal:
a. (windows and macos)
ngrok http 1000
b. (linux)ngrok http 5323
- Copy the forwarding URL it generates to use in the next step
Setting up your Pieces VS Code extensionβ
Now we will set up your Pieces VS Code extension to connect to your machine with Pieces OS.
- Open VS Code on your machine
- Go to VS Code Settings
β/CTRL + ,
- Ensure that you have the
Workspace
tab selected - Search
pieces custom url
- Paste your new forwarding URL in the input for
Pieces: Custom Url
Reloading your VS Code windowβ
Now we will reload your VS Code window to ensure that your Pieces VS Code extension is using your ngrok forwarding URL.
- Open up the Command Palette
β/CTRL + Shift + P
- Search
Reload Window
- Select
Developer: Reload Window