r/Devvit • u/Afraid-Emotion-6182 • 1d ago
Help Using the Devvit CLI when Reddit is blocked in your country (DNS-over-HTTPS workaround)
Reddit is blocked at the DNS level in some countries (Tajikistan in my case): the carrier answers Reddit lookups with 127.0.0.1. The site may still open through a VPN in the browser, but devvit login, devvit playtest and devvit upload fail with ENOTFOUND or ECONNREFUSED, because Node does its own DNS lookups.
What worked for me without changing any system settings: a small Node preload that resolves only Reddit hostnames over DNS-over-HTTPS (Cloudflare, by IP, so it doesn't need DNS itself) and leaves everything else alone.
- Save this as
tools/reddit-dns.cjsin your project:
const dns = ;
const https = ;
const REDDIT_HOST = /$/i;
const cache = ;
const originalLookup = dns.;
;
- Load it in your npm scripts:
"login": "NODE_OPTIONS=\"--require ./tools/reddit-dns.cjs\" devvit login",
"dev": "NODE_OPTIONS=\"--require ./tools/reddit-dns.cjs\" devvit playtest",
"deploy": "NODE_OPTIONS=\"--require ./tools/reddit-dns.cjs\" devvit upload"
- Run
npm run login, thennpm run devas usual.
Notes:
- If the block is by IP rather than DNS, this won't help; you'll need a VPN that also covers the terminal (WARP worked for me).
- On a flaky connection, a playtest upload can die halfway with "write EPIPE". Restarting
npm run devre-uploads. If you then see "AppVersion already exists", restarting once more cleared it for me.
Happy to help if you're stuck on the same thing.
1
u/Icy-Examination-2255 1d ago
Really neat solution.