**Connecting with a .ovpn File**

I have a .ovpn file, but I don’t know how to connect to it on NixOS. Initially, I wanted to use PPTP, as the networkmanager-pptp package was available on Arch, but I checked and it is not available on NixOS, so I can’t connect using that method.

Now, I need guidance on how to connect to the .ovpn file, which is for OpenVPN, on NixOS. I’ve imported the file into NetworkManager, but it keeps showing “connecting…” and never connects.

If you have any solutions, whether for PPTP or OpenVPN, I would appreciate your help. My goal is simply to get it working.

So to be clear you have done something like

nmcli connection import type openvpn file $file ?

Have you looked in the journal? What does

journalctl -u NetworkManager

have to offer? You can also change the log level of network manager if the logs aren’t telling you anything:

  networking.networkmanager = {
    enable = true;
    logLevel = "INFO";
  };
1 Like

Another simple way would be:

  1. Place the ovpn-file somewhere, e.g. your home directory
  2. Adapt the configuration of your NixOS host with something along those lines:
  services.openvpn.servers = {
    myVPN = {
      config = ''
        config /home/user/myvpn.ovpn
        auth-user-pass /home/user/myvpn.cred
      '';
      autoStart = false;
    };
  };
  1. Rebuilt and start the service with systemctl start myVPN and watch the logs for this service

Thanks for your guidance, but this seems to be like adding it manually via the UI, just like before. It gets added, but the problem persists; it just shows "connecting. ":weary: Here are the logs I got:

amir@nixos ~/Downloads> journalctl -u NetworkManager
May 23 14:17:33 nixos systemd[1]: Starting Network Manager...
May 23 14:17:34 nixos systemd[1]: Started Network Manager.
May 23 14:29:26 nixos systemd[1]: Stopping Network Manager...
May 23 14:29:26 nixos NetworkManager[1135]: <warn>  [1747997966.2291] dispatcher: (9) failed (after 0.001 sec>
May 23 14:29:26 nixos systemd[1]: NetworkManager.service: Deactivated successfully.
May 23 14:29:26 nixos systemd[1]: Stopped Network Manager.
May 23 14:29:26 nixos systemd[1]: NetworkManager.service: Consumed 606ms CPU time, 21.1M memory peak, 11.5M r>
-- Boot 877234002b2049f5a0d086f5d494618b --
May 23 14:29:54 nixos systemd[1]: Starting Network Manager...
May 23 14:29:55 nixos systemd[1]: Started Network Manager.
May 23 14:30:03 nixos NetworkManager[1183]: <warn>  [1747998003.0868] device (wlo1): no secrets: No agents we>
May 23 14:30:03 nixos NetworkManager[1183]: <warn>  [1747998003.0869] device (wlo1): Activation: failed for c>
May 24 14:34:32 nixos systemd[1]: Stopping Network Manager...
May 24 14:34:32 nixos NetworkManager[1183]: <warn>  [1747998272.3809] dispatcher: (9) failed (after 0.000 sec>
May 24 14:34:32 nixos systemd[1]: NetworkManager.service: Deactivated successfully.
May 24 14:34:32 nixos systemd[1]: Stopped Network Manager.
May 24 14:34:32 nixos systemd[1]: NetworkManager.service: Consumed 288ms CPU time, 21.1M memory peak, 11.6M r>
-- Boot fd4bf67596184ffd8cddbdaa49a01810 --
May 24 14:34:49 nixos systemd[1]: Starting Network Manager...
May 24 14:34:50 nixos systemd[1]: Started Network Manager.
May 24 14:34:58 nixos NetworkManager[1122]: <warn>  [1747998298.3064] device (wlo1): no secrets: No agents we>
May 24 14:34:58 nixos NetworkManager[1122]: <warn>  [1747998298.3066] device (wlo1): Activation: failed for c>
May 24 14:40:17 nixos systemd[1]: Stopping Network Manager...
May 24 14:40:17 nixos NetworkManager[1122]: <warn>  [1747998617.0724] dispatcher: (9) failed (after 0.001 sec>
May 24 14:40:17 nixos systemd[1]: NetworkManager.service: Deactivated successfully.
May 24 14:40:17 nixos systemd[1]: Stopped Network Manager.
May 24 14:40:17 nixos systemd[1]: NetworkManager.service: Consumed 241ms CPU time, 21.5M memory peak, 11.6M r>
```"

Thank you for your time. Unfortunately, this also didn’t work for me. Is there a way to enable PPTP for NetworkManager in NixOS? It worked on EndeavourOS, and I really need it.

Are you running nm-applet or some other secrets manager? How are you activating the connection? What happens if you do

nmcli conn up $vpn

what happens if you do

nmcli conn up --ask $vpn

where $vpn is the name assigned to your vpn connection.

nmcli conn show

will list your connections if you don’t know the name.

I am basing this off

May 24 14:34:58 nixos NetworkManager[1122]: <warn>  [1747998298.3064] device (wlo1): no secrets: No agents we>

because the rest of the line is No agents were available for this request, typically generated ovpn file do not have the password in them. Please setup your pager to wrap, or disable the pager when providing logs (man journalctl for pager settings). You did not increase the logging verbosity either. It would be helpful if you did this.

1 Like
amir@nixos ~/D/SirjanConf [10]> nmcli conn show
NAME                UUID                                  TYPE      DEVICE 
Wifi-6              498b6826-9bba-4997-8bd5-ec08fdf88f90  wifi      wlo1   
lo                  f5d244c2-2ac5-44e6-a57e-06447c291dc0  loopback  lo     
Amir                3df8c98b-3d2f-4f95-bf02-0cdf8e83d661  wifi      --     
AndroidAP_4479      138263cb-ea07-4e44-8234-16c8a2195d1f  wifi      --     
Qaem 2-WiFi 4       d1101817-aac3-4bc9-862d-f2f0b9b9ad37  wifi      --     
Sirjan              862dddb1-8842-49a3-98e0-b5d4b1dd69b7  vpn       --     
Wired connection 1  eb766b9d-eae1-3c12-9ddc-81aa172feb75  ethernet  --
amir@nixos ~/D/SirjanConf> nmcli conn up Sirjan
Error: Connection activation failed: The connection attempt timed out
Hint: use 'journalctl -xe NM_CONNECTION=862dddb1-8842-49a3-98e0-b5d4b1dd69b7 + NM_DEVICE=wlo1' to get more details.
amir@nixos ~/D/SirjanConf [4]> journalctl -xe NM_CONNECTION=862dddb1-8842-49a3-98e0-b5d4b1dd69b7 + NM_DEVICE=wlo1
Jun 11 18:49:22 nixos NetworkManager[16855]: <warn>  [1749655162.9433] ndisc[0xcb39940,"wlo1"]>
Jun 11 18:51:34 nixos NetworkManager[16855]: <warn>  [1749655294.8655] ndisc[0xcb3b2f0,"wlo1"]>
Jun 11 19:02:03 nixos NetworkManager[16855]: <warn>  [1749655923.0193] ndisc[0xcacdf20,"wlo1"]>
Jun 11 19:03:39 nixos NetworkManager[16855]: <warn>  [1749656019.0633] ndisc[0xcb41b00,"wlo1"]>
Jun 11 19:09:23 nixos NetworkManager[16855]: <warn>  [1749656363.7364] ndisc[0xcb35350,"wlo1"]>
Jun 11 19:10:26 nixos NetworkManager[16855]: <warn>  [1749656426.6156] ndisc[0xcb2eab0,"wlo1"]>
Jun 11 19:13:56 nixos NetworkManager[16855]: <warn>  [1749656636.6966] ndisc[0xcb313f0,"wlo1"]>
Jun 11 19:15:47 nixos NetworkManager[16855]: <warn>  [1749656747.4176] ndisc[0xcb4ad90,"wlo1"]>
Jun 11 19:22:31 nixos NetworkManager[16855]: <warn>  [1749657151.4706] ndisc[0xcb2ea00,"wlo1"]>
Jun 11 19:27:13 nixos NetworkManager[16855]: <warn>  [1749657433.2566] ndisc[0xcb313f0,"wlo1"]>
Jun 11 19:31:12 nixos NetworkManager[16855]: <warn>  [1749657672.2323] ndisc[0xcb313f0,"wlo1"]>
Jun 11 19:33:14 nixos NetworkManager[16855]: <warn>  [1749657794.1589] ndisc[0xcb313f0,"wlo1"]>
Jun 11 19:33:47 nixos NetworkManager[16855]: <warn>  [1749657827.1495] ndisc[0xcb313f0,"wlo1"]>
Jun 11 19:37:18 nixos NetworkManager[16855]: <warn>  [1749658038.5293] ndisc[0xcaea450,"wlo1"]>
Jun 11 19:39:05 nixos NetworkManager[16855]: <warn>  [1749658145.5310] device (wlo1): link tim>
Jun 11 19:39:05 nixos NetworkManager[16855]: <warn>  [1749658145.5321] device (wlo1): Activati>
Jun 11 19:40:02 nixos NetworkManager[16855]: <warn>  [1749658202.6214] ndisc[0xcb3f2f0,"wlo1"]>
Jun 11 19:43:00 nixos NetworkManager[16855]: <warn>  [1749658380.4041] vpn[0xcac81f0,862dddb1->
Jun 11 19:43:14 nixos NetworkManager[16855]: <warn>  [1749658394.6759] vpn[0xcb16790,862dddb1->
Jun 11 19:44:22 nixos NetworkManager[16855]: <warn>  [1749658462.5309] vpn[0xcb17360,862dddb1->
Jun 11 19:45:06 nixos NetworkManager[16855]: <warn>  [1749658506.1569] ndisc[0xcaa8550,"wlo1"]>
Jun 11 19:53:54 nixos NetworkManager[16855]: <warn>  [1749659034.4433] ndisc[0xcaa8550,"wlo1"]>
Jun 11 19:56:06 nixos NetworkManager[16855]: <warn>  [1749659166.8945] ndisc[0xcb179f0,"wlo1"]>
Jun 11 20:08:41 nixos NetworkManager[16855]: <warn>  [1749659921.0465] ndisc[0xcb179f0,"wlo1"]>
Jun 11 20:11:33 nixos NetworkManager[16855]: <warn>  [1749660093.5310] vpn[0xcb2a7b0,862dddb1->

this my output

The logs are useless because they are all cut off. Please fix your pager or switch it off.

journalctl --no-pager -u NetworkManager -b

for instance. You can trim to some time range using --since --before. Please increase the log level. Honestly, I’m not sure I can help you here, because I don’t think I have the patience to get to the bottom of this.

1 Like

Hey bro, thanks a lot for all your help so far. Just give me one last lead to figure out where the issue is. It’s highly unlikely to be a NixOS-specific problem, so if I just get a hint, I’ll follow up on it myself. Really appreciate your efforts!

Here’s my log:

Jun 11 20:56:33 nixos nm-openvpn[3122]: NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Jun 11 20:56:33 nixos nm-openvpn[3122]: TCP/UDP: Preserving recently used remote address: [AF_INET]192.168.50.50:443
Jun 11 20:56:33 nixos nm-openvpn[3122]: Attempting to establish TCP connection with [AF_INET]192.168.50.50:443
Jun 11 20:56:33 nixos nm-openvpn[3122]: TCP connection established with [AF_INET]192.168.50.50:443
Jun 11 20:56:33 nixos nm-openvpn[3122]: TCPv4_CLIENT link local: (not bound)
Jun 11 20:56:33 nixos nm-openvpn[3122]: TCPv4_CLIENT link remote: [AF_INET]192.168.50.50:443
Jun 11 20:56:34 nixos nm-openvpn[3122]: Connection reset, restarting [0]
Jun 11 20:56:34 nixos nm-openvpn[3122]: SIGUSR1[soft,connection-reset] received, process restarting