0

I'm trying to configure an HTTP server using Ubuntu 20.04 but I can't make any requests to the server. for example a simple express server like this

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
  res.send('Hello World!')
})

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)
})

on exmapleIp:3000 just wouldn't work I tried Nginx and same result happened here's the UFW


Status: active

To                         Action      From
--                         ------      ----
Nginx Full                 ALLOW       Anywhere
5432/tcp                   ALLOW       Anywhere
22/tcp                     ALLOW       Anywhere
80/tcp                     ALLOW       Anywhere
8080                       ALLOW       Anywhere
Nginx Full (v6)            ALLOW       Anywhere (v6)
5432/tcp (v6)              ALLOW       Anywhere (v6)
22/tcp (v6)                ALLOW       Anywhere (v6)
80/tcp (v6)                ALLOW       Anywhere (v6)
8080 (v6)                  ALLOW       Anywhere (v6)

I did tried disabling ufw but no luck with that neither. I did actually run Postgres and I was able to connect to it using PGadmin but no luck with requests

ponez
  • 1
  • 3
  • Your code is correct. When you run it, do you see the "Example app..." message? – niry Jul 10 '21 at 21:24
  • Yup i tried running it on another server it works fine – ponez Jul 11 '21 at 04:48
  • You are listening on localhost, however, it looks like you are attempting to connect from external interface. See https://stackoverflow.com/questions/33953447/express-app-server-listen-all-interfaces-instead-of-localhost-only – niry Jul 11 '21 at 13:11
  • I'm using that simple hello world as an example that I can't send any kind of request to the server, I tried using this code on my own VPS and it works just fine but on the one that I'm working on right now it just wont – ponez Jul 12 '21 at 13:59

0 Answers0