DNA
DNA14mo ago

Cannot access web server from other network devices when compiled

Hello. Im kinda new to deno and i just compiled my first bigger project with deno, but when the task is running, i can access the website directly from my pc, but not from my phone, which is in the same network. This is my code:
import {serve} from "https://deno.land/std@0.188.0/http/server.ts";
serve(handler, {port: Number(env.PORT), onListen: () => console.log(`Listening on http://localhost:${env.PORT}`)});
import {serve} from "https://deno.land/std@0.188.0/http/server.ts";
serve(handler, {port: Number(env.PORT), onListen: () => console.log(`Listening on http://localhost:${env.PORT}`)});
7 Replies
MrKleeblatt
MrKleeblatt14mo ago
I guess if you ran the file directly through Deno without compilation it would work?
DNA
DNA14mo ago
Forgot to add that to my message, but yes Works wo/ any issues Without compilation (just deno run main.ts), it works completely fine
MrKleeblatt
MrKleeblatt14mo ago
Which OS do u use?
DNA
DNA14mo ago
Windows 11 22H2 22621.1702 64bit
MrKleeblatt
MrKleeblatt14mo ago
Works for me on Linux, maybe has something to do with the windows compile system...
DNA
DNA12mo ago
Is there an update to this?
ybabts
ybabts12mo ago
Yes I believe you can choose for the server to listen on a specific host name, just use the host name 0.0.0.0 instead of the default 127.0.0.1. But I'd have to test it later and try and replicate your problem.