I have a website running on Apache on EC2 Ubuntu instance.
Now I wanted to install “n8n” and was following a tutorial that required nginx. So I installed nginx and becuase apache was running on port 80, i configured nginx to run on port 8080.

This is what I did.

First, I edited the nginx.conf file (Certbot certificate was added later).
My n8n instance runs on port 5678.

server {
listen 8080;
server_name sub.domain.com;
location / {
    proxy_pass http://localhost:5678;
    proxy_set_header Connection '';
    proxy_http_version 1.1;
    chunked_transfer_encoding off;
    proxy_buffering off;
    proxy_cache off;
}

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/sub.domain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/sub.domain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

Then I also edited the default file to add the port number:

server {
    listen 8080 default_server;
    listen [::]:8080 default_server;

If I run nginx -t I get this:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

But when I try to run the server, I get this error:

2024/04/03 22:31:49 [emerg] 13119#13119: bind() to 0.0.0.0:443 failed (98: Unknown error)
2024/04/03 22:31:49 [emerg] 13119#13119: bind() to 0.0.0.0:443 failed (98: Unknown error)
2024/04/03 22:31:49 [emerg] 13119#13119: bind() to 0.0.0.0:443 failed (98: Unknown 
error)
2024/04/03 22:31:49 [emerg] 13119#13119: bind() to 0.0.0.0:443 failed (98: Unknown error)
2024/04/03 22:31:49 [emerg] 13119#13119: bind() to 0.0.0.0:443 failed (98: Unknown error)
2024/04/03 22:31:49 [emerg] 13119#13119: still could not bind()

Any idea what I might be doing wrong here?

Thanks