Question

Apache Continually Resetting To Port 443

Posted July 19, 2021 174 views
ApacheLet's EncryptCloud ComputingDebian 9

I’ve encountered an issue with my website that I can’t seem to find a solution for, after multiple days of searching. In order to run the website, ports 80 and 443 need to be free. Apache uses those ports as a default, so that creates a conflict that causes the website to not go up. I’ve gotten Apache to switch ports from 80 to 8081, but when I try the same thing with port 443 (switching to port 9090), it continually resets back to 443. It’s driving me up the wall!

I’m very much a beginner with Linux and website code as a whole, so please be patient with me- if it comes down to it, I can try to make the website itself listen to a different port, but that’s a process I don’t even know how to begin. Both ports should be open and functional- port 8081 is for certain.

I don’t know what logs would be relevant here, but I’d be happy to fetch whatever’s needed. Currently, it’s running on Debian 9. This whole issue started when ACME v1 was shut down and I updated to ACME v2- beforehand I barely had to touch the code on my site at all, as it was a fork of a now-abandoned project. Which does mean I don’t know it as well as I likely should.. Whoops.

Thank you so much for taking the time to look at my question, and apologies in advance if I miss something obvious! Any advice at all is greatly appreciated

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @novabee,

First, let me know why do you want Apache to listen on other ports rather than 80 and 443. I mean don’t your websites use Apache or you are using NodeJS or something different?

Regarding Apache and listening port 443 and 80:

Replace the Listen directives in your apache config. The config should contain line like

Listen 80
Listen 443

Apache will listen on the ports defined with these configuration options. Replace them, and Apache will listen on a different port.

However, you still need to tell Apache what to serve on the ports above. Suppose you want Apache to start listening on port 8080 (plain), and 4433 (ssl). Then you need to replace the Listen directives to

Listen 8080
Listen 4433

After this if you have any VirtualHosts for your domains you need to edit them as well. Go to /etc/apache2/sites-enabled/ and in each file edit the lines where it says it’s listening on the old ports. Save the configurations and restart Apache.

  • I looked into it and it does turn out.. the site is using NodeJS. As I’ve tried changing Apache’s port configs many, many times (8081 it likes just fine, but it keeps adding 443 back in..), I’m assuming therein lies the issue!

    I don’t believe I have any VirtualHosts to worry about (the file directory was empty), so do you have any simple tutorials on getting Apache and NodeJS to get along? I’ve searched for solutions on my own, but I’m a little brainfried at this point, so I wouldn’t mind taking the easy way, haha.
    Thank you so much for your help!

    • Update: Was wrong about the VirtualHosts, there is one that I’ve also edited now. I’ve tried implementing a proxy-based solution for getting around this issue, but I’m still having it.. Although it may be because the only ones I can find are for HTTP ports, not HTTPS.

      Apache is listening on the replacement port, (now 8080 in case the number was somehow the problem, it wasn’t) so I know that bit works! But for some reason, every time its running, it adds back port 443. So at this point it seems to me that I need to either find a way to block exclusively Apache from port 443, or remove whatever keeps adding that port back in.

      • Hi @novabee,

        If you are trying yo use Apache as a proxy to NodeJS, I’ll recommend using Nginx instead. Apache is not that good at doing proxy just like you can see for yourself.

        Regarding the port, that is indeed strange, maybe it’s added somewhere else apart from where you are changing the port which is causing this.