Guide authored by: Ido Rikover
This solution was developed and summarized based on a troubleshooting session with Gemini and revised with clarifications from system support.
This is a complete guide to configure Visual Studio Code to run graphical applications (like Python's turtle, tkinter, or matplotlib) from a remote HUJI CS server (like river, rory, or melody) on your local Windows computer.
Important: This guide assumes you are connected to the Eudoroam network, or to the Rumba VPN if you’re not at university.
Start- Install SSH Remote extension by Microsoft, and login
1. Install the https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh extension in VS Code
2. Click on Remote Explorer in the left sidebar
3. Open a new remote
4. Write the SSH command – “ ssh -CY your-cs-username@river.cs.huji.ac.il “ without the quotes, your actual cs username instead of your-cs-username, and replace river with the host you're using. (First years use river)
5. Enter the password.
Only continue if this works, and if you’re connected.
When you try to run a graphical app, you get an error like:
- _tkinter.TclError: no display name and no $DISPLAY environment variable
- _tkinter.TclError: couldn't connect to display
- Or, you get a confusing VS Code pop-up about "port 10".
These errors happen because VS Code doesn’t set the $DISPLAY variable by itself, and because it auto-forwards ports.
We will fix this by manually creating the connection. This solution sets the $DISPLAY variable.
We will configure 3 separate components:
- VcXsrv (Your Local "Screen"): The program on your Windows PC that receives the graphics.
- Your SSH config File (The "Tunnel"): A file on your PC that tells SSH how to build the tunnel.
- VS Code (The "Instructions"): Settings to tell VS Code how to use the tunnel.
This program acts as a virtual monitor on your Windows desktop for the remote applications.
- Install VcXsrv: Download and install it from SourceForge.
- Launch VcXsrv (XLaunch): Find "XLaunch" in your Start Menu. You must configure it with these specific settings every time you start it.
- Display settings: Choose "Multiple windows" -> Click Next.
- Client startup: Choose "Start no client" -> Click Next.
- Extra settings: This is the most important screen.
- CHECK the box for "Disable access control".
- UNCHECK the box for "Native opengl" (to prevent bugs).
- Click Next, then Finish. An "X" icon will appear in your system tray.
- Allow Through Firewall: The first time you run this, Windows Firewall will pop up.
- CHECK BOTH boxes for "Private" and "Public" networks.
- Click "Allow access".
This file on your PC tells the "Remote - SSH" extension how to connect. We will tell it to build our manual tunnel every time it connects to river.
- Find the file: Open your local Windows File Explorer. In the address bar, type %USERPROFILE%\.ssh\config and press Enter.
- If the file config (with no extension) exists, open it in Notepad or VS Code.
- If it doesn't exist, create it (right-click -> New -> Text Document, name it config and delete the .txt extension).
- Use .ssh folder, not ssh.
- Edit the file: Paste the following exactly as written. Replace your-cs-username with your own cs login name, and river with the host you're using.
Host river.cs.huji.ac.il
HostName river.cs.huji.ac.il
User your-cs-username
Compression yes
# This is the magic line:
# It connects port 6010 on the server to port 6000 on your local PC (where VcXsrv is).
RemoteForward 6010 127.0.0.1:6000
We need to edit two separate settings.json files.
- Open VS Code (on your local PC, before connecting).
- Open the Command Palette (F1 or Ctrl+Shift+P).
- Type and select Preferences: Open User Settings (JSON).
- Add this line to the file. This stops VS Code's "auto-forwarding" from breaking our manual tunnel.
JSON
"remote.autoForwardPorts": false
- Now, connect to river.cs.huji.ac.il in VS Code.
- Once you are connected, open the Command Palette again (F1 or Ctrl+Shift+P).
- Type and select Preferences: Open Remote Settings (JSON).
- This is a different file stored on the server. Paste this code into it:
JSON
{
"terminal.integrated.env.linux": {
"DISPLAY": "127.0.0.1:10.0"
}
}
(This solves the "no display variable" error. It manually tells all new terminals on the server to send graphics to display :10.0, which corresponds to our tunnel's port 6010.)
All the settings are now correct, but you must restart everything to clear any old, broken connections.
- Clean Up Old Ports:
- While connected to the server, look for the "Ports" tab in the bottom panel (near "Terminal").
- If you see any ports listed (like "port 10"), right-click them and select "Stop Forwarding Port". We don't need them anymore.
- Quit VS Code: Click File > Exit.
- Exit VcXsrv: Right-click the "X" icon in your system tray and click Exit.
- Start VcXsrv: Launch "XLaunch" from your Start Menu (remember to check "Disable access control").
- Start VS Code: Relaunch the application.
- Connect to river.cs.huji.ac.il.
- Open a new terminal in VS Code (click the + icon).
- Run echo $DISPLAY. It should print 127.0.0.1:10.0.
- Run your Python script: python3 turtle_code.py
Your Python Turtle window should now appear on your desktop!
Errors: If you run into any issues, close remote connection in VSCode, and reconnect. That usually solves them.
If any more issues come up, feel free to send them in the comments so I can add a fix in the guide.