Skip to main content

nyord-vpn: NordVPN for macOS, one command

nyord-vpn go JP and your Mac is in Japan. That's the whole idea.

nyord-vpn is a Python CLI and library that connects macOS to NordVPN over OpenVPN. It fetches the live server list from NordVPN's v2 API, picks the least-loaded server in your target country, manages the openvpn subprocess, verifies the new IP, and cleans up after itself.

Visual

A laptop slipping through the globe to Mount Fuji, drawn in one line

Quick start

pip install nyord-vpn
brew install openvpn                     # the client shells out to it

export NORD_USER="your@email.com"        # NordVPN service credentials
export NORD_PASSWORD="your_password"

nyord-vpn go JP                          # connect to Japan
nyord-vpn info                           # current IP, server, country
nyord-vpn bye                            # disconnect

Connecting needs admin rights — macOS asks for your system password (not your NordVPN one) because OpenVPN reconfigures network interfaces.

Requirements

  • macOS
  • OpenVPN — brew install openvpn
  • Python 3.10+
  • A NordVPN account (use the service credentials from "Manual setup", not your dashboard login)

CLI

nyord-vpn go JP            # connect to Japan
nyord-vpn go DE --verbose  # connect to Germany, show every step
nyord-vpn go US --dry-run  # pick a server and print it — connect to nothing (no root needed)
nyord-vpn info             # show current IP, server, country
nyord-vpn list-countries   # list available country codes
nyord-vpn bye              # disconnect

--dry-run is the fast way to check that server selection and the API work before you involve sudo and OpenVPN.

Python API

import os
from nyord_vpn import Client, VPNError

client = Client(
    username_str=os.environ["NORD_USER"],
    password_str=os.environ["NORD_PASSWORD"],
)

client.go("NL")  # connect to the Netherlands
status = client.status()  # {"connected": True, "ip": "...", "server": "..."}
print(f"Connected via {status['server']} — IP {status['ip']}")
client.bye()  # disconnect

Scripts that actually connect need to run with sudo -E so root inherits your credentials.

How it works

nyord-vpn go US
  ├── NordVPNAPI          fetches the server list from api.nordvpn.com/v2
  ├── ServerManager       filters OpenVPN TCP servers in the country, picks lowest load
  ├── VPNConnectionManager
  │     ├── writes a temporary auth file, chmod 600, before writing the password
  │     ├── resolves the bundled .ovpn config for the server
  │     ├── spawns the openvpn subprocess (via sudo)
  │     └── polls until the IP changes, then verifies it against a public IP echo
  └── saves ephemeral state to ~/Library/Caches/nyord-vpn/state.json

Server selection: lowest load (a 0–100 percentage from the API) wins. If the API is unreachable after a successful call, the client reuses its in-memory server cache for the rest of the session.

Security: the auth file holding your password is chmod 600 and lives in the OS cache directory, never in config or the repo. See Security notes.

Package structure

Path Purpose
core/client.py Client — the high-level entry point that coordinates everything
api/api.py NordVPN v2 API client with per-instance caching
api/v2_servers.py Typed models and fetch for the v2 servers endpoint
network/server.py Server discovery, validation, and load-based selection
network/vpn.py OpenVPN subprocess lifecycle and IP verification
storage/state.py Persist and restore connection state
utils/templates.py Locate and cache the bundled .ovpn config files
exceptions.py VPNError, VPNConnectionError, VPNAPIError, and friends

Environment variables

Variable Purpose
NORD_USER (or NORDVPN_LOGIN) NordVPN service username
NORD_PASSWORD (or NORDVPN_PASSWORD) NordVPN service password

Troubleshooting

When OpenVPN won't start or the sudo prompt confuses you, see the troubleshooting guide. The short version: check which openvpn, run with --verbose, and read ~/Library/Caches/nyord-vpn/openvpn.log.

Contributing

uvx hatch run test:default        # run tests
uvx hatch run quality:fix         # ruff check --fix + format
uvx hatch run quality:typecheck   # mypy

Follow Conventional Commits.

License

MIT. See LICENSE.

Metadata

Release files for nyord-vpn 2.7.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nyord-vpn 2.7.7
File Size Uploaded Provenance Actions
nyord_vpn-2.7.7.tar.gz 419.4 kB With provenance Details for nyord_vpn-2.7.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nyord-vpn 2.7.7
File Interpreter ABI Platform Actions
nyord_vpn-2.7.7-py3-none-any.whl Python 3 none any Details for nyord_vpn-2.7.7-py3-none-any.whl

Total release size: 487.3 kB

Release files / nyord_vpn-2.7.7.tar.gz

Download URL nyord_vpn-2.7.7.tar.gz
Size 419.4 kB
Tags Source
SHA-256 checksum
How to use checksums
be3d826773e2f4f39496dadc4360067e5fb907ae1211a623da21fa99fa67beac
BLAKE2b-256 checksum
How to use checksums
61abf62e88ee9463c9b8ccc0bf826bafbf7b7507dc09cec4ae808cc687933c07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / nyord_vpn-2.7.7-py3-none-any.whl

Download URL nyord_vpn-2.7.7-py3-none-any.whl
Size 68.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f283d7c8485a65f5b18aac5b1d8689699a5bbfdab91210febba46422e385cf7
BLAKE2b-256 checksum
How to use checksums
649a6e05ea0d6a045d2fd9ab805a934dfb16a76ce1c87f525c7047d4476a1525
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Security for nyord-vpn 2.7.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nyord_vpn-2.7.7.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.7.7 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page