Score:0

Resolving default port 443 takes forever

lv flag

I have an expressjs server for my website. During development, it worked perfectly and while in deployment, I tried changing to default port 443 to get rid of the port in the url. However, this results in the domain not resolving at all. Even requests directly to the ip do not work. I am using an https server. Changing the port to basically anything else (that is allowed) works perfectly. Even specifying port 80 works (as the server is https and 80 is only for http). I cant seem to get my head around the problem. Here is the server side code

const express = require('express');
const router = express.Router();
const app = express();
const models = require('./models');
const https = require('https');
const fs = require('fs');

const key = fs.readFileSync('path/to/key'); // From 'letsencrypt'
const cert = fs.readFileSync('path/to/chain'); // From 'letsencrypt'

const options = {
    key: key,
    cert: cert
};

router.get('/', (req,res) => {
    res.send('No Route Found');
    generate_log(req)
});

var server = https.createServer(options, app);

app.use('/', router);

const port = 80

server.listen(port, () => {
    console.log(`server starting on port : ${port}`)
});

Any help would be greatly appreciated. Thanks. P.S. the firewall is configured correctly.

Edit

What I mean when Isay not resolving is that it takes forever to figure out that there is a problem. Specifically server not found. This only happens when I use 'https://my_site.io' to use the default 443 port. It works when the server is spun up on maybe port 8080 or even 80 'https://my_site.io:80'. This implies that it is rather a configuration error by me in ubuntu and not in the code itself.

ru flag
I would suggest posting this on Stack Overflow as this is not Ubuntu-specific.
Muhammad Yahya Warraich avatar
lv flag
I asked here only because I thought that this was more an OS problem then a software problem. Maybe stackexhange would be better. What do you think?
ru flag
"not resolving" doesn't make sense, we'd need more info what you mean about "not resolving" but as it stands this sounds like an application layer issue.
Muhammad Yahya Warraich avatar
lv flag
@ThomasWard Thanks for the feedback. Have updated accordingly.
ru flag
Server Not Found likely means that port 443 is timing out or some other issue. That could be Ubuntu related. When you run your server/application, and then do `sudo ss -tunlp | grep 443` and see if your application is listening properly.
Muhammad Yahya Warraich avatar
lv flag
@ThomasWard `tcp LISTEN 0 511 *:443 *:* users: "node",pid=51551,fd=19))` is what it outputs. It is listening but I am pretty sure that it should be 0.0.0.0:443 and not a wildcard 443.
ru flag
0.0.0.0 and * are synonymous. So we know that port 443 is being listened on. Do you have a firewall on this machine?
Muhammad Yahya Warraich avatar
lv flag
I do have a firewall. However I did configure it to allow connections to port 443 and 80 through ufw.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.