I am running ubuntu version 12.04 LTS and I have installed OpenVPN on it. After a while of troubleshooting why my client won't connect (I have generated keys and confligured the client), I ran 'service openvpn status' from the command line and received the following error:
could not access PID file for VPN 'server'
I have rebooted, started and restarted the service, but each time I check the status, I receive the PID error. I'm pretty sure that I can't connect because the service isn't running.
Where can I begin troubleshooting this? I don't know what to look for. Any help is greatly appreciated.
Thanks!
could not access PID file for VPN 'server'
means the PID file could not be read. This can have different reasons:sudo
?Thus, for further debugging, you will need to look at
/var/run/openvpn.server.pid
itselfIf the process is not running, your config is most probably wrong and you will have to read the logs why it did not start. Running
service openvpn start
might bring helpful output too.The init script just reporting that OpenVPN didn't start , and due to that
openvpn
can't read the pid file.You have to check
system/daemon/openvpn
log to see why couldn't start.Openvpn is configured in a way that allows running multiple instances of the service. This is very useful if you have different configurations as a client or as a server and you want to manage them separately.
The systemd configuration files for openvpn (located in /lib/systemd/system) include the "@" character, showing that you can enable different instances for the service. I have enabled some of the VPN connections with it. If, in addition to these configuration files decorated with "@", there is one without "@", you could enable only the connections required:
These instances, when started, should insert the correct option
Anyway, if you prefer testing something simpler, you could include the following line in /etc/openvpn/
<conf filename for the connnection>.conf
It seems like, you do not have an automatic start script! Which is usual. OpenVPN does not install such a thing by it self, as far as i know...
First of all try executing the server manually.
This will need an own Terminalwindows to run. And for the time OPENVPN is running this way, the TerminalWindow will not be usable for other stuff.
Try this (replace /etc/openvpn/config-files/ with your Path):
Some Information will appear in this Window.
Now try to connect to the Server with a client. You can shut the openvpn down by hitting CTRL+C
If this was the solution, do following for executing the OpenVPN-Server after your System has booted.
Do this in the terminal:
and tipe in the following lines:
This would be for the Server. Of course you have to change /etc/openvpn/config-files/ to your Path!!!
For Clients do the same, just be sure to choose the client.conf!
Then you'll add this script, to start after the system booted.
Do this in the terminal:
It might say hes missing headers. You can ignore that for now.
I'm not sure what "defaults" does, I think it means to start as a "normal" programm, after finishing booting and doing deep System stuff.
The startup script will just try to start OpenVPN, but it will not give you any error messages if it fails. Manually execute OpenVPN
And solve any errors that you see there. If you do not see errors, check that you did not set
log
to off, and maybe increase verbosity withverb
.By default, Ubuntu ships OpenVPN with a legacy startup script. This makes Upstart unable to restart service when it crashes. Legacy scripts also make use of pid files, which are not necessary with native Upstart jobs. So having a native job looks like a solution to your problem.
I've written Upstart job definition for OpenVPN myself and use it for 2 years without problems. Download the files below, then replace your /etc/init.d/openvpn with a symlink to /lib/init/upstart-job, run
sudo initctl reload-configuration
. You can edit /etc/default/openvpn to customize deamon startup (by default all VPNs from /etc/openvpn/ are run). Instances (CONN variable for connection job) are named after /etc/openvpn/*.conf files, without extension./etc/init/openvpn-connection.conf
/etc/init/openvpn-autostart.conf
/etc/default/openvpn
This solution is compatible up to Ubuntu 14.04 LTS, there are minor issues with 14.10 and in 15.04 Upstart is gone.