Skip to content

aws lightsail need restart after every 24 hour for keep continious service of an application called outline or openvpn

1

I use a software called Outline to connect to a VPN on my phone and PC, utilizing my server on AWS Lightsail. However, after every 24 hours, my VPN stops working. I then have to go back to my Lightsail server, stop it, restart it, and reconfigure the process. After doing so, it works fine. At first, I thought the issue might be with the Outline VPN itself, so I tried a different application called OpenVPN, but the problem persisted. Then, I considered that since I live in China, the issue might be related to the IP address. To test this theory, I attempted using a static IP, but unfortunately, nothing seems to resolve the problem. Can you please provide guidance on how to solve this issue?

1 Answer
0

Greeting

Hi Zahid,

Thank you for sharing the details of your situation! It sounds like you've done an impressive amount of troubleshooting already by trying different VPN software, considering the impact of where you live, and experimenting with static IPs. Let's work together to pinpoint the root cause and ensure your AWS Lightsail-based VPN runs smoothly without needing daily restarts. 😊


Clarifying the Issue

From your description, the issue arises after 24 hours of use, where the VPN connection (via Outline or OpenVPN) stops functioning until you manually restart your Lightsail server. This suggests a possible configuration, resource, or networking issue on the server side rather than the VPN application itself. You've tested using a static IP and noted no improvement, ruling out transient IP address issues. Living in your country adds another layer of complexity due to potential restrictions or network conditions.


Why This Matters

Consistent and uninterrupted VPN service is essential for secure internet access, particularly in restrictive environments. The need for daily server restarts interrupts usability and undermines the reliability of the solution. Resolving this will provide you with a seamless VPN experience, essential for maintaining connectivity and productivity.


Key Terms

  • AWS Lightsail: A simplified virtual private server (VPS) platform by AWS.
  • Outline VPN: A VPN service designed for ease of use and enhanced privacy.
  • OpenVPN: An open-source VPN protocol widely used for secure communications.
  • Static IP: A permanent IP address assigned to a server for consistent accessibility.
  • Firewall: A network security system that controls incoming and outgoing traffic.
  • Keep-alive: A mechanism to ensure a connection remains open by sending periodic signals.

The Solution (Our Recipe)

Steps at a Glance:

  1. Check Server Logs for Errors
  2. Review Lightsail Resource Allocations
  3. Verify Networking and Keep-Alive Settings
  4. Set Up Automated Service Restarts

Step-by-Step Guide:

1. Check Server Logs for Errors
Logs provide clues about what happens during the 24-hour period that leads to the failure. On your Lightsail instance:

sudo journalctl -u outline  
sudo journalctl -u openvpn  

Look for recurring errors or warnings near the 24-hour uptime mark. These could indicate resource exhaustion or configuration issues.


2. Review Lightsail Resource Allocations
Insufficient server resources (CPU, RAM, or bandwidth) can cause crashes. To check usage:

htop  # View real-time resource usage  
df -h  # Check disk space  
free -m  # Check memory usage  

Consider upgrading your Lightsail plan if resources are consistently maxed out.


3. Verify Networking and Keep-Alive Settings
Ensure your firewall and network settings allow uninterrupted VPN traffic:

  • On your instance, confirm ports used by Outline/OpenVPN are open:
sudo ufw allow 1194/tcp  # OpenVPN default port  
sudo ufw allow 443/tcp   # HTTPS (Outline uses this)  
  • Add keep-alive options to your VPN configuration to prevent timeouts:
    For OpenVPN:
keepalive 10 120  

4. Set Up Automated Service Restarts
If no critical errors are found, automate service restarts to preempt failures:

  • Create a systemd timer for Outline:
sudo nano /etc/systemd/system/outline-restart.timer  

Add:

[Unit]  
Description=Restart Outline VPN Service Every 24 Hours  

[Timer]  
OnBootSec=1min  
OnUnitActiveSec=24h  

[Install]  
WantedBy=timers.target  
  • Create the service file:
sudo nano /etc/systemd/system/outline-restart.service  

Add:

[Unit]  
Description=Restart Outline VPN Service  

[Service]  
ExecStart=/bin/systemctl restart outline  
  • Enable and start the timer:
sudo systemctl enable outline-restart.timer  
sudo systemctl start outline-restart.timer  

Repeat similar steps for OpenVPN if needed.


Closing Thoughts

Resolving the issue requires a combination of resource monitoring, log review, and possibly automating restarts. If resource limits are the problem, upgrading your Lightsail instance or optimizing the VPN configuration should help.

For further details, you might find the following documentation helpful:

Let me know if you'd like to dive deeper into any of these steps, Zahid! 🚀😊


Farewell

Best of luck resolving this! Feel free to reach out again if you hit any snags—I’m here to help. 🌟


Cheers,

Aaron 😊

answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.