expressjs / express

Fast, unopinionated, minimalist web framework for node.
https://expressjs.com
MIT License
65.63k stars 16.22k forks source link

ERR_EMPTY_RESPONSE every time i try to access from a device not local #5008

Open jman13378 opened 2 years ago

jman13378 commented 2 years ago

so im trying to create an express server but i get ERR_EMPTY_RESPONSE(from a VPN) on other devices and my friends got ERR_CONNECTION_TIMED_OUT

how can i fix this

enyoghasim commented 2 years ago

can you help with a screenshot i want to confim something

jman13378 commented 2 years ago

Screenshot_20221004_181614

const express = require('express')
const app = express()
const fs = require('fs')
app.use(express.static('public'))
var lel = app.get('/', function (req, res) {
}).get('/site', function (req, res) {
  fs.readFile('./public/site.html', async function(err, data) {
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.write(data);
    return res.end();
  });

}).get('/api/get/guilds', async function (req, res) {
  res.send(`${await client.guilds.cache.size}`)
}).get('/api/get/members', async function (req, res) {
  res.send(`${await client.users.cache.size}`)

}).get('/api/get', function (req, res) {
  fs.readFile('./public/api/get/', async function(err, data) {
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.write(data);
    return res.end();
  });

}).listen(port,"0.0.0.0", ()=>{
  console.log(`Listening port on ${lel.address().port}`)
});
enyoghasim commented 2 years ago

sorry for asking is the ip a publicly accessible ip address?

or that of localhost

jman13378 commented 2 years ago

that was my pc's ipv4 but my public ip address does the same thing. My ipv4, localhost, and public address work on local devices

enyoghasim commented 2 years ago

ok can you try using ngrok to expose the local port and lets see how that goes?

jman13378 commented 2 years ago

it works but i would rather use my ip

enyoghasim commented 2 years ago

i guess the main issue is the ip adress.

i guess its not being exposed

dougwilson commented 2 years ago

It is also possible there is a firewall involved, either on the device itself or the network between the two machines. If you are able to at least get a reaponse on loopback (i.e. 127.0.0.1), then the issue is outside of the express.js framework and something network, machine, or node.js.

jman13378 commented 2 years ago

image image image

dougwilson commented 2 years ago

Hi @jman13378 I am certainly sorry you are having trouble. It is unfortunately we are not sure what the issue is exactly that you are experiencing and we are not also experiencing. That puts us in a hard place to help. If you believe this is an issue in Express.js, it may help if you can help provide pointers for where you are seeing the issue in our code and we can perhaps work towards what code changes we need to make, or you're always welcome to contribute such a change directly. Other than that, I'm not sure how else we can help.

enyoghasim commented 2 years ago

It is also possible there is a firewall involved, either on the device itself or the network between the two machines. If you are able to at least get a reaponse on loopback (i.e. 127.0.0.1), then the issue is outside of the express.js framework and something network, machine, or node.js.

yea @dougwilson because ngrok also works according to him

dougwilson commented 2 years ago

Well, here is a test @jman13378 : see if the following code has the same issue or not. This will narrow down for if the Express.js project can assist or not:

const http = require('http')
const app = http.createServer((req, res) => res.end('Hello, world!'))
app.listen(3000, "0.0.0.0")
jman13378 commented 2 years ago
const http = require('http')
const app = http.createServer((req, res) => res.end('Hello, world!'))
app.listen(3000, "0.0.0.0")

not that

jman13378 commented 2 years ago

its most likely an ISP issue or Firewall

sheplu commented 2 years ago

were you able to solve the issue ? or is it still not working ?

Looking on my side like other people said it is most likely some kind of firewall / blocking the request

jman13378 commented 2 years ago

I will try in my pi but other than that I have not fixed it