Bitcoin Forum
July 22, 2026, 09:01:12 PM *
News: Latest Bitcoin Core release: 31.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How can I expose a Python P2P blockchain node running on Android behind CGNAT?  (Read 77 times)
Francesco Ferraro (OP)
Newbie
*
Offline

Activity: 4
Merit: 0


View Profile WWW
July 21, 2026, 11:18:29 AM
 #1


Hi everyone,

I'm building a blockchain as a hobby and learning project.

The node is written in Python (Flask) and runs entirely on Android using Termux.

Everything works correctly on a local network:

Block mining

Transaction validation

UTXO management

Block synchronization

Peer-to-peer communication (LAN)


The only problem is making the node publicly reachable.

My mobile carrier uses CGNAT, so I cannot expose port 5000 directly.

So far I've tried:

DuckDNS

LocalToNet


DuckDNS doesn't work because I don't have a public IP.

LocalToNet creates a tunnel, but it displays a warning/interstitial page before forwarding traffic. That breaks API communication between peers.

My node exposes endpoints such as:

GET  /info
GET  /chain
POST /receive_block
POST /receive_tx
POST /submit_block

Because of the warning page, other nodes cannot communicate with these endpoints normally.

My goal is not to build a centralized network.

I only need a reliable bootstrap (seed) node so new peers can discover the network.

Since I'm developing entirely on an Android phone with mobile data, I'd like to know what the best approach would be.

Would you recommend:

A free VPS?

FRP (Fast Reverse Proxy)?

Cloudflare Tunnel?

WireGuard?

Another CGNAT-friendly solution for P2P applications?


I'd really appreciate advice from anyone who has solved a similar problem.

Thank you.
Italian Panic
Hero Member
*****
Offline

Activity: 1078
Merit: 712



View Profile WWW
Today at 07:58:25 AM
 #2

Hi Francesco, welcome in this amazing forum and compliments for trying to set a node in android.
The problem as you say is that your provider CGNAT don't give you a public IP address but an IP shared with much more user. In fact LocalToNet workwith human user and not with automatic API.
In my opinion, you should try the cloudflare tunnel which creates an encrypted tunnel from your phone to cloudflare network, bypassing the CGNAT and you don't need ports or VPS, thereby avoiding HTML blocks.

 
  KYCNOTLIST.COM  
█████
██
██
██
██
██
██
██
██
██
██
██
█████
██████████████████████████████████████████████████████████████████████████████████
 
🔍
██████████████████████████████████████████████████████████████████████████████████
█████
██
██
██
██
██
██
██
██
██
██
██
█████
|
▬▬▬✅️▬▬▬
Comprehensive
 Database 

▬▬▬▬▬▬▬
▬▬▬✅️▬▬▬
KYC/AML
 Levels 

▬▬▬▬▬▬▬
▬▬▬✅️▬▬▬
Independent
 Analysis 

▬▬▬▬▬▬▬
| 
...CHECK NOW....
 
...TOR MIRROR...
NotATether
Legendary
*
Offline

Activity: 2394
Merit: 9895


┻┻ ︵㇏(°□°㇏)


View Profile WWW
Today at 08:45:29 AM
 #3

You are going to have a hard time with background usage as Android limits what apps can do in the background.

You can disable battery optimization for your app in the settings, but honestly, network drops will still be a problem, even if you never disconnect the WiFi, just because the devices or uplink can drop the signal.

 
 b1exch.to 
  ETH      DAI   
  BTC      LTC   
  USDT     XMR    
.███████████▄▀▄▀
█████████▄█▄▀
███████████
███████▄█▀
█▀█
▄▄▀░░██▄▄
▄▀██▄▀█████▄
██▄▀░▄██████
███████░█████
█░████░█████████
█░█░█░████░█████
█░█░█░██░█████
▀▀▀▄█▄████▀▀▀
ABCbits
Legendary
*
Offline

Activity: 3668
Merit: 10212



View Profile
Today at 09:33:34 AM
 #4

Have you consider using VPN that support port forwarding? It's sometimes suggested when people ask how their Bitcoin node can accept incoming connection. But you either need to find VPN provider that give port forwarding or manually setup your own VPN instance on a server (that can accept incoming connection normally).

███████████████████████████
███████▄████████████▄██████
████████▄████████▄████████
███▀█████▀▄███▄▀█████▀███
█████▀█▀▄██▀▀▀██▄▀█▀█████
███████▄███████████▄███████
███████████████████████████
███████▀███████████▀███████
████▄██▄▀██▄▄▄██▀▄██▄████
████▄████▄▀███▀▄████▄████
██▄███▀▀█▀██████▀█▀███▄███
██▀█▀████████████████▀█▀███
███████████████████████████
.
.Duelbits PREDICT..
█████████████████████████
█████████████████████████
███████████▀▀░░░░▀▀██████
██████████░░▄████▄░░████
█████████░░████████░░████
█████████░░████████░░████
█████████▄▀██████▀▄████
████████▀▀░░░▀▀▀▀░░▄█████
██████▀░░░░██▄▄▄▄████████
████▀░░░░▄███████████████
█████▄▄█████████████████
█████████████████████████
█████████████████████████
.
.WHERE EVERYTHING IS A MARKET..
█████
██
██







██
██
██████
Will Bitcoin hit $200,000
before January 1st 2027?

    No @1.15         Yes @6.00    
█████
██
██







██
██
██████

  CHECK MORE > 
Francesco Ferraro (OP)
Newbie
*
Offline

Activity: 4
Merit: 0


View Profile WWW
Today at 04:51:47 PM
 #5

You are going to have a hard time with background usage as Android limits what apps can do in the background.

You can disable battery optimization for your app in the settings, but honestly, network drops will still be a problem, even if you never disconnect the WiFi, just because the devices or uplink can drop the signal.

Hi NotATether,

Thank you for the advice.

Yes, Android background limitations are something I have to consider.

At the moment, I'm disabling battery optimization during testing and keeping the node active in Termux.

My current goal is simply to prove that a lightweight blockchain node can run reliably on Android before optimizing for long-term uptime.

Thank you for pointing this out.
Francesco Ferraro (OP)
Newbie
*
Offline

Activity: 4
Merit: 0


View Profile WWW
Today at 05:06:08 PM
 #6

Hi Francesco, welcome in this amazing forum and compliments for trying to set a node in android.
The problem as you say is that your provider CGNAT don't give you a public IP address but an IP shared with much more user. In fact LocalToNet workwith human user and not with automatic API.
In my opinion, you should try the cloudflare tunnel which creates an encrypted tunnel from your phone to cloudflare network, bypassing the CGNAT and you don't need ports or VPS, thereby avoiding HTML blocks.


Hi Italian Panic,

Thank you for your explanation.

Yes, the LocalToNet warning page is exactly what breaks communication between blockchain peers because it returns HTML instead of JSON.

I'll test Cloudflare Tunnel again and see whether it can reliably forward JSON API traffic between nodes.

Thank you for the suggestion.
Francesco Ferraro (OP)
Newbie
*
Offline

Activity: 4
Merit: 0


View Profile WWW
Today at 05:28:43 PM
 #7

Have you consider using VPN that support port forwarding? It's sometimes suggested when people ask how their Bitcoin node can accept incoming connection. But you either need to find VPN provider that give port forwarding or manually setup your own VPN instance on a server (that can accept incoming connection normally).


Hi ABCbits,

Thank you for the suggestion.

I hadn't considered VPN providers with port forwarding before.

I'll research VPN solutions that support inbound port forwarding and compare them with Cloudflare Tunnel and FRP.

Thank you for the idea.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!