I'm using a VPN service, but so far I've only been using it on my computer. Now I'd like to have it on my phone as well. The service I use allow up to four simultaneous connections, so that isn't an issue. They don't have their own client for Android, but they do make config files available for download and use with any client that supports OpenVPN. I've tried OpenVPN Connect, and it works quite well. However, whenever I switch between networks, for example when I lose my home WiFi on leaving my home, or when switching between public WiFis, it doesn't reconnect, so I have to remember to actively disconnect and reconnect.

I've tried setting up a macro in MacroDroid to automatically close OpenVPN Connect, wait for a few seconds, then reopen OpenVPN Connect, but all that does, is bring up the login screen, and I still have to manually click Connect.

My phone is rooted, and in case it matters, it's a Honor 8, FRD-L09 running EMUI 4.1. I'm not going to upgrade to 5.0 at this time, as TWRP and SuperSU have been reported not to be compatible with the EMUI 5.0 kernel. Other than that, I'm open to suggestions. I'm not afraid to play with shell scripts, as long as I have some understanding of what the script does, and with this, I have no idea how to implement it in a shell script, so if if you have such a solution, please also explain what it actually does.

EDIT: OpenVPN Connect has the ability to create shortcuts to disconnect and connect on the homescreen. I'm assuming that these shortcuts just pass arguments to the executable, telling it what to do, and what config file to use. If I knew how to find what arguments the shortcuts pass, I'd likely be able to write a shell script that I could then call from MacroDroid upon network change.

  • @AndyYan was mentioning shadowsocks as an option to keep VPN persitent across disconnects. Not sure of it is the same one with that name on Play Store. He would respond I suppose since he is tagged ( else please search chat room where he elaborated on this in a comment to me and you can follow up on that )
    – beeshyams
    Mar 17, 2017 at 17:37
  • @beeshyams Unfortunately no. Apparently they've done some work on this, because last time I tested it, a few months ago, it didn't even try to reconnect. Now it does seem to work when going from WiFi to LTE or 3G, but still not when going from LTE/3G to WiFi.
    – user207189
    Mar 17, 2017 at 18:04
  • This may give you some pointers
    – beeshyams
    Mar 17, 2017 at 18:29
  • 1
    @beeshyams Will do. Thanks for the tip. While not strictly a requirement to do this with MacroDroid, it'd be a very welcome solution.
    – user207189
    Mar 18, 2017 at 2:50
  • 1
    @beeshyams I'm aware of that. However, the versions I have access to (EMUI 5.0 for Honor 8 and Lineage for Galaxy S3 and S5) only support PPTP and IPSec, and the VPN service I use only runs over SSL. As far as I know, PPTP has been considered insecure for several years. I don't know enough about IPSec to reject or embrace it, but since my VPN service of choice doesn't support it, I don't use it. Thanks for the input though.
    – user207189
    Dec 28, 2017 at 6:26

3 Answers 3


This seems to have been caused by either a bug or an oversight by the app developer, and it sorted itself after an update. Just make sure the OpenVPN client is recent.

Also, the following settings are worth checking.

Reconnect on reboot. Enable it unless you want to manually decide when to OpenVPN and when not to.

Seamless tunnel. Enabling it blocks all internet traffic while the VPN is (re)-connection, to avoid leaking your real IP.

Connction timeout. How long to try re-acquiring the connection if it is lost. Set this to CONTINOUSLY RETRY to keep trying until a connection is established. If a timeout is set, and a connection has not been established before it runs out, OpenVPN Connect will exit, and the connection will be unblocked, to let you connect unprotected until you manually restart OpenVPN Connect.

Moreover, keep in mind, that reconnect on reboot only works if OpenVPN Connect is connected when you initiate the reboot. If you manually disconnected or if you lost the connection, you need to manually reconnect after rebooting.


Try to check keeplive option in your server and client config. For example "keepalive 5 40" will send test packet every 5 seconds, and will reconnect after 40 seconds. So when you switched from Wifi to mobile internet it will reconnect after 40 sec. Of course you can use less options, 1 10...

  • This sorted itself out with some update of the OpenVPN client for Android, and now works flawlessly without the need for stuff like MacroDroid or Tasker. Moreover, I'm using a commercial VPN service, hence I do not have access to the server's config. I'm upvoting your answer, but I'm not accepting it, since I can't really try it out.
    – user207189
    Dec 6, 2017 at 15:00

Have you checked the Settings in OpenVPN Connect (in the burger menu, top left)? There is an option to reconnect automatically and an option to block connectivity when the VPN is offline. However I have not tried it with multiple connections.

  • I had tried all options about automatic connection, and they did work when coming back to the same network I had lost, but not when moving to a different network, such as moving between mobile and WiFi or between different WiFi:s. However, it sorted itself out after an update, as I also pointed out in the comment to @DavidK's answer as of Dec 6 2017. +1 because the suggestion is sound, but I can't accept because the problem was most likely a bug or an oversight by the app developer, and it has been fixed.
    – user207189
    Oct 17, 2018 at 20:37
  • @DuaneDibbley It's OK, I'm happy it's a valid suggestion and it might help someone else. Thank you. Since you have found a solution, you could maybe write your own answer and accept it.
    – Rolf
    Oct 19, 2018 at 1:23

You must log in to answer this question.