How to Install Pritunl VPN Server on AlmaLinux 9 or Rocky Linux 9
Install Pritunl and MongoDB 8.0 on AlmaLinux 9 or Rocky Linux 9 from the official repositories, complete the web setup and create your first VPN server and user.
Pritunl is a VPN server with a web console for managing users, organizations and servers. It runs OpenVPN and WireGuard connections and stores its configuration in MongoDB. This guide installs Pritunl and MongoDB 8.0 on AlmaLinux 9 or Rocky Linux 9 from the official repositories, completes the first-run setup in the web console and creates a first VPN server and user. The commands are the same on Oracle Linux 9, which the Pritunl project develops and tests on and recommends, and on RHEL 9.
CentOS 7 reached end of life in June 2024. Pritunl's current packages for the RHEL family are published for version 9, and its documentation names AlmaLinux as a good choice when Oracle Linux is not available. Two things have changed compared with older tutorials: SELinux stays enabled, because Pritunl ships its own SELinux policy, and the database is MongoDB 8.0 rather than the 3.x series.
Requirements
- A server running AlmaLinux 9 or Rocky Linux 9 (x86_64) with a public IP address.
- A user with
sudorights. - A firewall in front of the server that you control, such as the one in your hosting control panel. Pritunl manages the server's own packet filter rules, so
firewalldis switched off in step 2. - Optional: a DNS name such as
vpn.example.compointing at the server, if you want a trusted certificate for the web console.
Step 1: Add the MongoDB and Pritunl repositories
Create the MongoDB 8.0 repository file:
sudo tee /etc/yum.repos.d/mongodb-org.repo << EOF
[mongodb-org-8.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/9/mongodb-org/8.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://pgp.mongodb.com/server-8.0.asc
EOF
Create the Pritunl repository file. The oraclelinux/9 path is the one Pritunl documents for all RHEL 9 based distributions:
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/oraclelinux/9/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
Step 2: Install Pritunl and MongoDB
Update the system:
sudo dnf -y update
Pritunl writes its own iptables rules, and the Pritunl documentation has you remove iptables-services and disable firewalld so they do not interfere. Before you do, make sure your provider's firewall only allows the ports listed in step 6, because the host firewall will no longer filter traffic for you:
sudo dnf -y remove iptables-services
sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service
Install the packages. pritunl-openvpn is Pritunl's own OpenVPN build, which its documentation requires on RHEL distributions:
sudo dnf -y install pritunl pritunl-openvpn wireguard-tools mongodb-org
dnf asks you to accept the two repository signing keys on first use. Enable and start both services:
sudo systemctl enable mongod pritunl
sudo systemctl start mongod pritunl
Step 3: Raise the open file limit
Pritunl recommends a higher open file limit to avoid connection problems under load:
sudo sh -c 'echo "* hard nofile 64000" >> /etc/security/limits.conf'
sudo sh -c 'echo "* soft nofile 64000" >> /etc/security/limits.conf'
sudo sh -c 'echo "root hard nofile 64000" >> /etc/security/limits.conf'
sudo sh -c 'echo "root soft nofile 64000" >> /etc/security/limits.conf'
Step 4: Connect Pritunl to the database
Open https://203.0.113.10 in a browser, using your server's address. The console uses a self-signed certificate at this point, so accept the browser warning. The database setup page asks for a setup key and a MongoDB URI. Print the setup key on the server:
sudo pritunl setup-key
Paste the key into the form. Leave the MongoDB URI at its pre-filled value, which points to the MongoDB instance on the same server, and save.
Step 5: Sign in and finish the initial setup
The console now shows a login form. The default user name is pritunl. Print the default password:
sudo pritunl default-password
After you sign in, the initial setup dialog lets you set your own user name and password. Do that now. The public address of the server is detected automatically. If you pointed a DNS name at the server, enter it in the Let's Encrypt domain field to replace the self-signed certificate; this needs port 80 to be reachable, because Pritunl runs a second web server there for certificate validation and for redirecting HTTP to HTTPS.
Step 6: Create an organization, a user and a server
- On the Users page, add an organization, then add a user to it. Give the user a PIN if you want a second factor at connection time.
- On the Servers page, add a server. Pritunl proposes a random UDP port and a random virtual network; note the port. Tick the WireGuard option if you want WireGuard connections as well, which adds a second port.
- Attach the organization to the server and start the server.
Then open these ports in your provider's firewall:
| Port | Purpose |
|---|---|
| 443/tcp | Web console, and profile sync for Pritunl clients |
| 80/tcp | Let's Encrypt validation and redirect to HTTPS |
| The server port (UDP by default) | OpenVPN connections |
| The WG port (UDP), if enabled | WireGuard connections |
Restrict port 443 to the addresses of your administrators where you can.
Step 7: Connect a client and verify
On the Users page, download the user's profile or copy a temporary profile link, and import it into the Pritunl client or any OpenVPN client. Connect, then check that the user shows as online in the console and that your public IP address is now the server's.
On the server, confirm that both services are running and that Pritunl started in its SELinux domain. The first log line after a start includes the SELinux context, which should contain pritunl_t:
sudo systemctl status mongod pritunl
sudo journalctl -u pritunl | grep selinux_context
If the context is unconfined or missing, the Pritunl SELinux policy is not active; check that SELinux is in enforcing mode with getenforce.
Updates and troubleshooting
Pritunl and MongoDB are updated with the rest of the system:
sudo dnf -y update
If the web console does not load, check sudo journalctl -u pritunl -n 50 and make sure nothing else is listening on port 443. The console port can be changed with sudo pritunl set app.server_port 443, replacing 443 with the port you want. If clients connect but have no internet access on a cloud platform, check whether the platform blocks forwarded traffic; the Pritunl documentation mentions the source/destination check on AWS and the IP forwarding option on Google Cloud. The Pritunl installation and configuration pages are the reference for these steps.
Frequently asked questions
Is Pritunl free?
The Community edition is free and, according to the Pritunl site, runs on a single host with unlimited users, servers and devices. Premium and Enterprise are paid subscriptions billed per host; Enterprise adds features such as single sign-on, automatic failover, replicated servers and site-to-site links.
Do I have to disable SELinux?
No. Pritunl includes SELinux policies for its main process and its web server process, and its documentation says that running with SELinux significantly improves security. These policies are supported on Oracle Linux, AlmaLinux and Rocky Linux. Leave SELinux in enforcing mode.
Can MongoDB run on a different server?
Yes. For a single host, MongoDB on the same server is the documented setup. For a cluster of several Pritunl hosts, all hosts must use the same MongoDB database, and Pritunl recommends a dedicated database server; enter its connection URI on the database setup page instead of the local default.
Does Pritunl work on Ubuntu?
The documentation includes instructions for Ubuntu 24.04, but states that the repository is continuously tested only on RHEL distributions and that future Ubuntu support is not tested or guaranteed. For a new server, a RHEL 9 based distribution is the safer choice.