[GH-ISSUE #1275] Ntfy on Android: can't connect to Ntfy server (on wifi) behind VPN when restricted to wifi only #900

Open
opened 2026-05-07 00:28:35 +02:00 by BreizhHardware · 1 comment

Originally created by @GideonBear on GitHub (Feb 6, 2025).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1275

🐞 Describe the bug

When I set Ntfy to "wifi only" in my settings (Samsung), it fails to connect to my Ntfy server over a WireGuard VPN, even on wifi (mobile data is off). When "Mobile data or wifi" is selected, it connects fine.

💻 Components impacted

Android app

💡 Screenshots and/or logs

https://nopaste.net/9iBLnfgCnN

🔮 Additional context

When "wifi only" is selected, I do get notifications over mobile data. Attachments fail to download.
This is probably related, and also an issue for me; I want to use as little mobile data as possible.

Originally created by @GideonBear on GitHub (Feb 6, 2025). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1275 :lady_beetle: **Describe the bug** <!-- A clear and concise description of the problem. --> When I set Ntfy to "wifi only" in my settings (Samsung), it fails to connect to my Ntfy server over a WireGuard VPN, even on wifi (mobile data is off). When "Mobile data or wifi" is selected, it connects fine. :computer: **Components impacted** <!-- ntfy server, Android app, iOS app, web app --> Android app :bulb: **Screenshots and/or logs** <!-- If applicable, add screenshots or share logs help explain your problem. To get logs from the ... - ntfy server: Enable "log-level: trace" in your server.yml file - Android app: Go to "Settings" -> "Record logs", then eventually "Copy/upload logs" - web app: Press "F12" and find the "Console" window --> https://nopaste.net/9iBLnfgCnN :crystal_ball: **Additional context** <!-- Add any other context about the problem here. --> When "wifi only" is selected, I do get notifications over mobile data. Attachments fail to download. This is probably related, and also an issue for me; I want to use as little mobile data as possible.
Author
Owner

@Ravindranathrl commented on GitHub (Feb 25, 2025):

I've investigated this issue and found that it likely stems from how the WireGuard VPN routes traffic when restricted to "Wi-Fi only." The error logs indicate a java.net.ConnectException: Failed to connect to /172.17.0.1:1420, which suggests that the app is trying to connect to a local IP that may not be accessible over the VPN when only Wi-Fi is enabled.

Add the following to your WireGuard configuration to ensure all traffic, including Wi-Fi-only traffic, routes through the VPN:

AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 25

Use a Public IP Address Instead of a Local IP:

Replace 172.17.0.1 with the public IP address or domain of your Ntfy server. This ensures that traffic is routed correctly through the VPN tunnel, even on Wi-Fi.

Adjust Android VPN Settings:

Set the VPN to Always-on VPN and enable Block connections without VPN in Android settings.

Disable Mobile Data Always Active in Developer Options (if available) to force the device to rely entirely on Wi-Fi.

Check App Permissions:

Ensure that the app has these permissions in the Android manifest:

<!-- gh-comment-id:2681119347 --> @Ravindranathrl commented on GitHub (Feb 25, 2025): I've investigated this issue and found that it likely stems from how the WireGuard VPN routes traffic when restricted to "Wi-Fi only." The error logs indicate a java.net.ConnectException: Failed to connect to /172.17.0.1:1420, which suggests that the app is trying to connect to a local IP that may not be accessible over the VPN when only Wi-Fi is enabled. Add the following to your WireGuard configuration to ensure all traffic, including Wi-Fi-only traffic, routes through the VPN: AllowedIPs = 0.0.0.0/0, ::/0 PersistentKeepalive = 25 Use a Public IP Address Instead of a Local IP: Replace 172.17.0.1 with the public IP address or domain of your Ntfy server. This ensures that traffic is routed correctly through the VPN tunnel, even on Wi-Fi. Adjust Android VPN Settings: Set the VPN to Always-on VPN and enable Block connections without VPN in Android settings. Disable Mobile Data Always Active in Developer Options (if available) to force the device to rely entirely on Wi-Fi. Check App Permissions: Ensure that the app has these permissions in the Android manifest: <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.VPN_SERVICE"/>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#900
No description provided.