中文 | English
For the localhost.webview.code Android WebView companion app.
This script deploys code-server with one command in the Termux environment on Android, using termux-services (runit) for lifecycle management and auto-start. After installation, a code shortcut is registered for all operations: install, update, uninstall, and mode switching.
Android Device
├── Termux
│ ├── code-server (127.0.0.1:8443)
│ │ ├── Self-signed certificate (auto-managed)
│ │ ├── Default Linux mode (process.platform polyfill)
│ │ └── termux-services (runit)
│ │ ├── sv up/down # Start/Stop
│ │ ├── sv status # Status
│ │ └── sv-enable # Auto-start
│ ├── ~/.config/code-server/
│ │ ├── config.yaml
│ │ └── rewrite-android2linux.js
│ └── $PREFIX/bin/code # Shortcut command
└── localhost.webview.code (WebView app)
└── https://localhost:8443/
| Decision | Reason |
|---|---|
127.0.0.1:8443 binding |
Local-only access, prevents insecure LAN connections |
--cert (no args) |
code-server auto-generates and manages self-signed certs |
| Default Linux mode | Works out of the box for most extensions |
| Optional Android mode | Required by Live Share and a few extensions needing native platform |
| Marketplace switching (install-time) | Live Share etc. must be installed from VS Code Marketplace, then restored to Open VSX |
| Auto-start after install | Zero manual steps — ready to connect immediately after deployment |
- Install Termux (F-Droid version; Google Play version is outdated)
- (Optional) Install Termux:Boot for system-level auto-start on boot
curl -fsSLo install.sh https://raw.githubusercontent.com/DieMoe233/localhost.webview.code/refs/heads/master/scripts/install.en.sh && bash install.shThe script performs these steps:
- Installs dependencies (
termux-services,openssl-tool,git,nodejs) - Installs
code-server(tur-repo) - Creates the
process.platformpolyfill - Interactive password setup
- Creates
config.yamland runit service - Installs preloaded extensions (Live Share, Copilot Chat, Chinese language pack, SSH FS)
- Registers the
codeshortcut - Auto-starts the service and enables auto-start
Open https://127.0.0.1:8443 after installation to start using.
After installation, use code instead of bash install.sh:
code start # Start service
code stop # Stop service
code restart # Restart service
code status # View status
code enable # Enable auto-start
code disable # Disable auto-start
code update # Update code-server
code reinstall # Force reinstall
code uninstall # Uninstall (prompts for full removal)
# Extension management
code extension install <ID> # Install extension
code extension list # List installed
code extension uninstall <ID> # Uninstall extension
# Mode switching
code linux # Switch to Linux mode (default)
code android # Switch to Android mode (required by Live Share)Installed in two phases:
code-server defaults to Open VSX, but some extensions (Live Share, GitHub Copilot Chat) are only available on the VS Code Marketplace. The script temporarily switches product.json → installs → restores.
| Extension | ID |
|---|---|
| VS Live Share | ms-vsliveshare.vsliveshare@1.0.5936 |
| GitHub Copilot Chat | GitHub.copilot-chat |
The default marketplace for code-server. Most extensions can be installed directly.
| Extension | ID |
|---|---|
| Chinese Language Pack | MS-CEINTL.vscode-language-pack-zh-hans |
| SSH FS | Kelvin.vscode-sshfs |
# Switch to Linux mode first to bypass platform checks:
code linux
# Then install:
code extension install <extension-id>
# Switch back to Android mode or keep Linux mode:
code androidcode linuxprocess.platform→"linux"(via polyfill)- Most extensions install and work normally
- Default mode, works out of the box
code androidprocess.platform→"android"(native value)- Use when native platform detection is required
Location: ~/.config/code-server/config.yaml
With password (entered during installation):
bind-addr: 127.0.0.1:8443
auth: password
password: <your-password>
cert: trueWithout password (skipped during installation):
bind-addr: 127.0.0.1:8443
auth: none
cert: true
bind-addris locked to127.0.0.1— local-only access. Passwordless mode is acceptable for this setup.
Restart the service after changing config: code restart
Location: ~/.config/code-server/rewrite-android2linux.js
Rewrites process.platform to "linux" to resolve Android platform compatibility issues. Injected via NODE_OPTIONS="--require" at startup in Linux mode, and automatically used during extension installation.
# Service runtime logs (stdout/stderr)
tail -f ~/.local/share/code-server/current
# Exit status logs (recorded on each exit)
cat ~/.local/share/code-server/exit.log# Linux mode
NODE_OPTIONS="--require $HOME/.config/code-server/rewrite-android2linux.js" \
code-server --bind-addr 127.0.0.1:8443 --cert
# Android mode
code-server --bind-addr 127.0.0.1:8443 --cert| Issue | Solution |
|---|---|
sv: command not found |
Available immediately after install. If not: source $PREFIX/etc/profile.d/termux-services.sh |
| Connection refused | Check service status: code status |
| code-server keeps restarting | View logs: tail -f ~/.local/share/code-server/current |
| Live Share not working | Ensure Live Share extension is installed; code-server 4.125.0+ supports Linux mode |
| Extension install blocked by platform check | Switch to Linux mode first: code linux && code extension install <ID> |
| Forgot password | View ~/.config/code-server/config.yaml or delete it and run code install |
| Running install when already installed | Shows help instead of reinstalling; use code reinstall to force |
code uninstallPrompts whether to fully remove code-server:
y→ Runspkg uninstall code-server+ removes$PREFIX/bin/coden→ Removes only config and service, keeps the binary (can be removed later withpkg uninstall code-server)