title: Serving files on a local network with Deno
body: <p>I recently decided to play around with <a href="https://deno.land/" rel="nofollow noreferrer">Deno</a> a bit.</p>
  
  <p>Right now I am trying to set up a basic file server on my local network, but it will only serve files to my computer and not the rest of the network (I can't even send a http request to the server from outside my computer). I can not, for the life of me, figure out why it only works locally.</p>
  
  <p>I have added the code I am using at the moment below just in case, but I'm pretty sure the problem is somewhere else, because I have the same problem with <a href="https://deno.land/std/http/file_server.ts" rel="nofollow noreferrer">this file_server example</a> and when I create a file server with <a href="https://github.com/oakserver/oak" rel="nofollow noreferrer">oak</a></p>
  
  <pre><code>import { serve } from 'https://deno.land/std@v0.42.0/http/server.ts';
  const server = serve({ port: 3000 });
  
  const decoder = new TextDecoder('utf-8');
  
  for await (const req of server) {
      const filePath = 'public' + req.url;
  
      try {
          const data = await Deno.readFile(filePath);
          req.respond({ body: decoder.decode(data) });
      } catch (error) {
          if (error.name === Deno.errors.NotFound.name) {
              console.log('File "' + filePath + '" not found');
              req.respond({ status: 404, body: 'File not found' });
          } else {
              req.respond({ status: 500, body: 'Rest in pieces' });
              throw error;
          }
      }
  }
  </code></pre>
  
  <p>The command I'm using to run  the file is:</p>
  
  <pre><code>deno --allow-all server.ts
  </code></pre>
  
  <p>When I create a simple file server in Node.js everything works just fine. It can serve files to my computer and any other device on the network.</p>
  
  <p>I think the fault is with my understanding of Deno and it's security concepts, but I don't know. I would greatly appreciate any help and can supply more details if required.</p>