Closed N72826 closed 2 years ago
Ok, creating a new comment just to avoid any confusion now that I have more to go off of. You can probably disregard the majority of my previous questions, except the question of, which of the two files that I modified actually changed the script? or did both modifications work to change it?
The script is running fine however, my system went to sleep(which I know how to prevent for future cases) so I received an error. Here is a log of what happened after I went to sleep:
user@RPI /t/nordvpn-reconnect (main)> nordvpn-reconnector
Initializing NordVPN reconnector with a maximum uptime of 1 hours
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Current uptime is 1 hours 2 minutes 19 seconds, which is greater than 1 hours
Attempting to reconnect.
Connecting to United States #8863 (us8863.nordvpn.com)
\Attempting to kill process 1435 for service nordvpnd
/usr/bin/nordvpn-reconnector: line 117: kill: (1435) - Operation not permitted
Failed to kill service; it may be that the service is running at a higher privilege than this script
Asking nordvpnd-killer.service to take care of this for us.
Whoops! Cannot reach System Daemon.
Whoops! Cannot reach System Daemon.
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
...checking again in 6 minutes written 40 more times
so if the system hadn't of locked automatically, "Asking nordvpnd-killer.service to take care of this for us." would have been performed without a hiccup? and I would have never received "Whoops! Cannot reach System Daemon."? cool.
I'm sorry but what the hell do I do now? I am willing to provide whatever is necessary for you to help me to the best of your abilities. Thank you.
Ok. Even after I prevented the system from auto locking, it failed to perform the task.
user@RPI ~> nordvpn connect P2P
Connecting to France #755 (fr755.nordvpn.com)
You are connected to France #755 (fr755.nordvpn.com)!
user@RPI ~> nordvpn-reconnector
Initializing NordVPN reconnector with a maximum uptime of 1 hours
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Checking again in 6 minutes
Current uptime is 1 hours 8 seconds, which is greater than 1 hours
Attempting to reconnect.
Connecting to France #755 (fr755.nordvpn.com)
\Attempting to kill process 1422 for service nordvpnd
/usr/bin/nordvpn-reconnector: line 117: kill: (1422) - Operation not permitted
Failed to kill service; it may be that the service is running at a higher privilege than this script
Asking nordvpnd-killer.service to take care of this for us.
Whoops! Cannot reach System Daemon.
Whoops! Cannot reach System Daemon.
Checking again in 6 minutes
^C⏎
Hey! Thank you for using this tool and reporting your issues here. We've all been there, so never worry about asking beginner questions (some of the stuff isn't that beginner though :D)
I'll try to cover as much as I can for posterity, even though you seem to have covered a lot of ground yourself.
First, a super brief primer on services: a service or a daemon is just any old executable code that is started by the init process (which is the first thing that starts on your machine) and therefore can always be assumed to be "up and running". Think about the process, for instance, that is responsible for making sure you are connected to the network using the right network interface. Setting these up is a pain and linking them to initd
(the init daemon, hence the d
at the end of the name) might be complicated. So, there are tools and frameworks out there that do this for you. One such system is systemd
(which does a lot of other things, too). You can talk to systemd
using its command-line interface, systemctl
. systemd
can auto-start an executable for you in one of the two spaces: (1) the root user space, or (2) the current logged-in user space.
Here is the architecture of the current tool:
nordvpn-reconnector.sh
script that is meant to be executed in the current user space. That is because we don't want the nordvpn
executable to try to look for log-in details in the root
user's config files and not find any. So, this is the script that is constantly trying to reconnect to VPN if needed.nordvpnd-killer.sh
which is meant to be executed in the root
system space. That's because the nordvpnd
service (the service that comes bundled with the nordvpn client and takes care of setting up the DNS rules, routing table, network interfaces, etc.) is run under root
and if we need to kill it, we have to have sufficient privileges.There are two files that are sister to the executable scripts above which are meant to tell systemd
how to execute these. So, here is what the install script does:
/opt
)./usr/bin
so that you can then type in the name of the script from your shell without having to specify the full path to the executable, since /usr/bin
is usually included in path
and whatever is in there can be auto-discovered.systemd
systemd
that it should run the units you just copied.To properly run the executables, you will need the two services up and running. If the nordvpnd-killer.service isn't running, then asking it to kill nordvpnd
will not work. You can check to see if the service is actually working by:
sudo systemctl status nordvpnd-killer.service
(you need the sudo
because this is a root
system space service).
We need the service to be loaded and active. Any time you want to get out of the locked state, you can manually do this:
touch /tmp/nordvpnd-killer.ask
which will create a file at /tmp/nordvpnd-killer.ask
and in a few seconds the killer service will take
your request and kill the hung up service for you.
To make sure that the reconnector service itself is running, you should use the systemctl
tool in
user space:
systemctl --user status nordvpn-reconnector.service
and again, we want loaded and actively running.
In terms of modifying the behavior: first off, this is open source. So the moment you clone it, it is yours and you can do whatever. But to keep consistent, I would advise you to modify the service units (the .service
files) and use that to export the proper environment variables to the shell script. You can either modify the files you clone, then install
, or you can install
and then modify the files that are installed on your system. Just don't forget to rerun the service via systemctl restart
.
To check on the status of the service, you can do any of these:
systemctl
to give you the most recent status lines: systemctl status nordvpn-reconnector
journalctl -u nordvpn-reconnector
@mmnaseri Dude thank you for providing this response, this is highly appreciated. I wanted to reply as quick as possible while I have you "here" so apologies if you already answered this.
Surely I will read over your reply fully and report any further questions, just right now I would like to know if:
did you get a chance to view my two previous comments? I know this question may be answered once I fully consider your response there, given I have just skimmed. but did you answer why:
Whoops! Cannot reach System Daemon.
is occurring?
I see you have provided me with enough to run it properly now, so that issue will most likely go away and the cause for why it's occurring is besides the point. It's just one of those things that I would like to know as well purely out of curiosity.
Anyways thanks again for the tool and the most elaborate help reply I have ever received for something on github.
No worries. I hate it personally when someone just throws a thread at you and expects you to go find the cloth. I usually try to leave enough info that you can build on. It seems that that can happen when the nordvpn service itself is either not started or not executed: https://www.linuxquestions.org/questions/slackware-14/nordvpn-app-whoops-cannot-reach-system-daemon-when-running-nordvpn-c-4175704486/
Further evidence that this is a NordVPN issue: https://www.reddit.com/r/nordvpn/comments/kfewlb/solution_whoops_cannot_reach_system_daemon_after/
@mmnaseri dude thank you, I found a bit of that answer on my own but removed it because I thought I had solved it. after the script failed, I ran nordvpn status and it replied with the message in this reddit thread Whoops! /run/nordvpn/nordvpnd.sock not found
https://www.reddit.com/r/nordvpn/comments/q4yxm8/after_update_runnordvpnnordvpndsock_not_found/
so I took the top comments advice, ran sudo systemctl start nordvpnd.service
but had to reboot to get nordvpn to work again.
Yep. That sounds about right. Seems like for some reason on many Debian-based distros the client service is not configured properly by default. I'm closing this issue, but feel free to reopen or open another one if anything else happens :)
@mmnaseri
● nordvpn-reconnector.service - NordVPN reconnector daemon
Loaded: loaded (/etc/xdg/systemd/user/nordvpn-reconnector.service; disabled; vendor preset:>
Active: active (running) since Mon 2021-12-20 03:22:25 EST; 1h 0min ago
Main PID: 3038 (bash)
Tasks: 2 (limit: 4073)
Memory: 880.0K
CPU: 2.419s
CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/nordvpn-reconnector.service
├─3038 bash /usr/bin/nordvpn-reconnector
└─4555 sleep 360s
Dec 20 04:22:27 RPI nordvpn-reconnector[3038]: Attempting to reconnect.
Dec 20 04:22:28 RPI nordvpn-reconnector[4361]: [72B blob data]
Dec 20 04:22:28 RPI nordvpn-reconnector[4361]: [4B blob data]
Dec 20 04:22:28 RPI nordvpn-reconnector[3038]: Attempting to kill process 1474 for service nordvpnd
Dec 20 04:22:28 RPI nordvpn-reconnector[3038]: /usr/bin/nordvpn-reconnector: line 118: kill: (1474) - Operation not permitted
Dec 20 04:22:28 RPI nordvpn-reconnector[3038]: Failed to kill service; it may be that the service is running at a higher privilege than this script
Dec 20 04:22:28 RPI nordvpn-reconnector[3038]: Asking nordvpnd-killer.service to take care of this for us.
Dec 20 04:22:43 RPI nordvpn-reconnector[4510]: [56B blob data]
Dec 20 04:22:43 RPI nordvpn-reconnector[4517]: [56B blob data]
Dec 20 04:22:44 RPI nordvpn-reconnector[3038]: Checking again in 6 minutes
~
~
~
~
~
~
user@RPI ~ [SIGINT]> nordvpn status
Whoops! Cannot reach System Daemon.
Yep, seems like there is definitely something wrong with your NordVPN installation if just running nordvpn status
is producing that error. Unfortunately, I don't know exactly how to help beyond linking to articles that are out there on the Internet.
Yep, seems like there is definitely something wrong with your NordVPN installation if just running
nordvpn status
is producing that error. Unfortunately, I don't know exactly how to help beyond linking to articles that are out there on the Internet.
damn ok. thanks for letting me know that fast! I don't really know how to proceed because you really can't go wrong installing it. I'll let you know if I find a solution.
I think one of the threads I have linked to above was suggesting uninstalling it from the main repo and directly getting the client from the nordvpn website
I think one of the threads I have linked to above was suggesting uninstalling it from the main repo and directly getting the client from the nordvpn website
ah ok thank you, I will try that!
Best of luck! If you don't mind, once you have a solution, could you post it here for posterity?
Best of luck! If you don't mind, once you have a solution, could you post it here for posterity?
absolutely! I would like to provide a solution for anyone in the future who may come across this thread. I would want the same for myself.
so that reddit thread is from about a year ago, and it suggests that I download version 3.7.4
which, at the time, was simply downgrading one version to make it work again. It's been a while and I don't know if I should install a version that old. I'll probably install the latest version once more just to make sure. also just realized, since I am on a raspberry pi 4, the latest arm version that can be installed is nordvpn_3.12.2_arm64.deb
20 min later : nordvpn status
still outputs "Whoops! Cannot reach System Daemon." after it's force quit. I attempted to follow the leading comments' advice, adding my current user to the nordvpn group, sudo usermod -aG nordvpn $USER
with no success. I also tried newgrp nordvpn
, no success.
A full reboot is required in order to use norm again after I run into this problem. frustrating.
checked this out, the pinned comment suggests a fix that seems to have worked for others. https://aur.archlinux.org/packages/nordvpn-bin/?O=190&PP=10 Still no solution. Can't believe after all my anticipation and efforts, finally thinking I was going to be able to run a vpn on a dedicated machine nearly 24/7, that a stupid bug like this would cause me so much trouble. just hurts thinking about it, maybe if I weren't on an arm build of norm this wouldn't be the case. but I am not changing the os on the pi. I feel like giving up since this is such a niche issue that is documented to have been solved by others very simply but on another os.
but I am not changing the os on the pi.
turns out I have another SD card on standby, going to load Raspbian OS on it, just to see if this solves the issue.
but I am not changing the os on the pi.
turns out I have another SD card on standby, going to load Raspbian OS on it, just to see if this solves the issue.
raspbian os actually performed worse than ubuntu. I could not even get nordvpn running correctly. gave up on that fairly quickly since none of the fixes that corrected the daemon and sock errors seemed to do anything on raspbian. I'm back on ubuntu and decided to export a log of the system. hopefully this may help in diagnosing the issue.
I have no idea why this is happening, but after nord is killed and brought back, it's failing to reach an address for the dns servers and a reboot is required to restore functionality to norm. let me know if you would like another link since I set it to automatically delete after being viewed. https://pastebin.com/iA8aAy7g starting at line 748 you can see nord-reconnector stepping in to do it's job since the minimum connection time was surpasssed. it continues at line 996, where it realizes it doesn't have perms for some reason so it resorts to the sister script provided as you can see at line 1014. after that, it's all downhill lmao
@mmnaseri sorry for spamming this thread btw, hopefully you only receive notifications when I explicitly mention you.
hey! so, looking at your extensive paste, it seems likely that your nordvpn client has trouble reaching the nordvpn servers:
Dec 21 07:52:36 RPI nordvpnd[10990]: 2021/12/21 07:52:36 error on making client request: Head "https://downloads.x9fnzrtl4x8pynsf.com/configs/dns/cybersec.json": dial tcp: i/o timeout
hey! so, looking at your extensive paste, it seems likely that your nordvpn client has trouble reaching the nordvpn servers:
Dec 21 07:52:36 RPI nordvpnd[10990]: 2021/12/21 07:52:36 error on making client request: Head "https://downloads.x9fnzrtl4x8pynsf.com/configs/dns/cybersec.json": dial tcp: i/o timeout
@mmnaseri hey man! glad you are back because I expended all searches. Why do you think that is occurring since I am able to connect just fine before the process is killed forcefully? And do you have any recommendations? I tried reinstalling and that didn't help.
I would start the debug process by first trying to find where the issue is occurring. Without using my script, first try to manually kill the service as root:
sudo systemctl stop nordvpnd
and see if that works. Do this before the connection hangs, since that usually means that disconnect attempts will also fail.
If that also puts you in a bad state, make sure that after killing the service, it is set to auto-restart:
sudo systemctl status nordvpnd
We expect to see the service as showing as active and loaded. If not, then the issue is that the service is not set to auto-restart after being stopped. In that case, see if this will get you out of a bad state:
sudo systemctl start nordvpnd
If it does, then I can add a line in the script to make sure that after a few seconds the service has auto-recovered or restart it manually via the script. This will most likely fix the issue for you.
If after killing the service it doesn't auto-start, but manually starting it fails, then your nordvpn installation is faulty. Let's cross that bridge when we come to it.
So, let's assume that at this point you either have a solution or you don't but the systemctl command starts the service properly. This means that now you can start the service portion of the nordvpn client, but somehow nordvpn connect
doesn't function as expected. In that case, we will need to narrow it down to one of these:
Follow the steps above and maybe we can debug this together :)
@mmnaseri Hey man it's been a minute, was busy but decided to give this a shot. So I followed your advice, don't know why I didn't think of trying to manually kill it myself, super effective way of isolating the issue. Anyways, I was able to successfully kill nord while connected, restart the service, and connect again without failure. I will provide a log below of everything I did including the status of the service. https://pastebin.com/FqAVUpVG
So your proposed fix would probably solve everything for me:
If it does, then I can add a line in the script to make sure that after a few seconds the service has auto-recovered or restart it manually via the script. This will most likely fix the issue for you.
thanks for everything man.
Hey! So, I think I have a bit that will help you in 1e08492c04f46aef0dcc6728645ce97fc1d6e003. Re-clone or fetch the changes and reinstall. Don't forget to first stop, disable, and uninstall the existing version before re-running the new version. Let me know if this helps :)
Hey! So, I think I have a bit that will help you in 1e08492. Re-clone or fetch the changes and reinstall. Don't forget to first stop, disable, and uninstall the existing version before re-running the new version. Let me know if this helps :)
don't think it got fixed sadly. nordvpn received an update as well.
nordvpn-reconnector.service - NordVPN reconnector daemon
Loaded: loaded (/etc/xdg/systemd/user/nordvpn-reconnector.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-01-21 22:48:13 EST; 1h 20min ago
Main PID: 1570 (bash)
Tasks: 2 (limit: 4073)
Memory: 22.8M
CPU: 2.114s
CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/nordvpn-reconnector.service
├─1570 bash /usr/bin/nordvpn-reconnector
└─6883 sleep 360s
Jan 21 23:54:15 RPI nordvpn-reconnector[1570]: Attempting to reconnect.
Jan 21 23:54:16 RPI nordvpn-reconnector[1570]: Attempting to kill process 1020 for service nordvpnd
Jan 21 23:54:16 RPI nordvpn-reconnector[1570]: /usr/bin/nordvpn-reconnector: line 118: kill: (1020) - Operation not permitted
Jan 21 23:54:16 RPI nordvpn-reconnector[1570]: Failed to kill service; it may be that the service is running at a higher privilege than this script
Jan 21 23:54:16 RPI nordvpn-reconnector[1570]: Asking nordvpnd-killer.service to take care of this for us.
Jan 21 23:54:31 RPI nordvpn-reconnector[4302]: [56B blob data]
Jan 21 23:54:31 RPI nordvpn-reconnector[4310]: [56B blob data]
Jan 21 23:54:31 RPI nordvpn-reconnector[1570]: Checking again in 6 minutes
Jan 22 00:00:31 RPI nordvpn-reconnector[1570]: Checking again in 6 minutes
Jan 22 00:06:31 RPI nordvpn-reconnector[1570]: Checking again in 6 minutes
● nordvpnd.service - NordVPN Daemon
Loaded: loaded (/lib/systemd/system/nordvpnd.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Sat 2022-01-22 00:10:00 EST; 3s ago
TriggeredBy: ● nordvpnd.socket
Process: 7551 ExecStart=/usr/sbin/nordvpnd (code=exited, status=1/FAILURE)
Main PID: 7551 (code=exited, status=1/FAILURE)
CPU: 106ms
user@RPI ~/Downloads> nordvpn status
Whoops! /run/nordvpn/nordvpnd.sock not found
if this helps at all, after it fails to reconnect, I attempted to rclone the repo just in case I didn't install the latest version and this happens.
user@RPI ~/Downloads> git clone https://github.com/mmnaseri/nordvpn-reconnect
Cloning into 'nordvpn-reconnect'...
fatal: unable to access 'https://github.com/mmnaseri/nordvpn-reconnect/': Could not resolve host: github.com
user@RPI ~/Downloads>
Can you verify that you have actually cloned the right version? This can be verified by looking at nordvpnd-killer.sh
and checking to see if the new lines from 1e08492 are present. It might be that due to failed name resolution (which happens when nordvpnd overwrites /etc/resolv.conf but the service is dead) you actually were never able to clone the right version of the repo.
Yes, I can verify I cloned the right version now. I uninstalled the older version of the script and re-cloned it after restarting the pi. (since it wouldn't allow me to connect github in order to clone without rebooting after the script failed to re-establish connection.)
I don't think the resolv.conf prevented me from cloning the updated version the first time though since it never threw me that error until after I tested the new version and it failed. After it failed, you told me to verify I actually cloned the right version so I went to clone it again and received that failed to access error because I hadn't rebooted yet.
@mmnaseri Apologies if you are busy, I know everyone has life to deal with. Is there is anything left to do? Sad that this never worked.
Just wanted to start off by saying. I love you for creating this. I highly appreciate it. I have a couple questions though, and can't seem to determine the answer on my own. I'm fairly new to linux but have managed to work my way through, so bare with me if I ask questions that may seem like common sense.
So first off I want to describe my intentions, I want it to set the minimum time to 2 hours instead of 4. And I would like to enable notifications (which are supposedly disabled by default). I also intend to install this as a service, which is relevant to one of my questions.
In order to accomplish these two changes regarding the minimum time and notifications, would I modify nordvpn-reconnect.sh in this way so that :
would become ->
or am I meant to just modify the environment variables in nordvpn-reconnector.service? or both?
The reason I am confused by this is because it just doesn't seem like I am supposed to touch the aforementioned nordvpn-reconnect.sh at all. I did end up modifying both instances mentioned and it installed fine, I just want to make sure I am doing this right.
I don't know how to check the status of the script either. I may be mistaken in that you aren't intended to use systemctl to check the status, I probably misread. I did figure out that I could type "nordvpn-reconnector" and it does confirm that I modified the minimum time but like I said, I don't know if my change to nordvpn-reconnect.sh or nordvpn-reconnector.service or both changes resulted in that modification. And on top of thatI don't exactly know what running "nordvpn-reconnector" does, but now that I think of it, that probably is to check the status I am just really uncertain.
Nothing went wrong when I utilized the simple installation command in order to enable it as a daemon as you can see below. Although, it was a bit concerning to see "Uninstalling nordvpn-reconnector" and the lines about removal below it in a command for the installation, but I trust in the creator of the script as I did not create this and that could simply be a typo/something I don't understand.
Two more things as of editing this an hour later. Firstly, I have "fish" installed so I see that when I type "nordvpn", two suggestions pop up for the possible commands. One for "nordvpn-reconnector" like I mentioned before, and "nordvpnd-killer". So, I guess this is the same question that I posed previously, but are both of these manual controls for the script? I was under the impression that once you installed as a daemon, these things were performed automatically. but I guess a reasonable explanation could be that the killer can be run manually through that command like you stated in the documentation:
and the "nordvpn-reconnector" command is just used to check the status? I am just really uncertain, apologies for my lack of knowledge and inability to understand the documentation despite how descriptive it is. I truly can't come up with an explanation for the next bit though:
so does this simply mean to "touch /tmp/nordvpnd-killer.ask"? ok, if it does, cool but I still don't understand what you mean when you say "run the other script as root" what other script? the killer?
and going by my assumption that "If you drop a file at" means to create one through touch, then the creation of "/tmp/nordvpn-reconnect.lock" halts the service until it's deleted. right?
Again, thank you so much for creating this and for hearing me out. I recently got everything set up how I wanted on a raspberry pi, only to realize NordVPN stalled and was impossible to disconnect without restarting the entire device. By sheer luck I stumbled onto your script and am grateful someone went out of their way to provide a solution. Apologies for this scrambled line of questioning, I think once you reply a ton of this will be cleared up because after coming back and reading the documentation again, most of my questions already answered themselves I just want to be certain.