Change/add the port to the ip address

Posted June 19, 2018 1.2k views
ApacheUbuntu 16.04

I’m trying to add another port to apache2 to listen to. I did all the steps in the following link, but still can’t get my page to load on another port number (tried 81, 8444, 8090).

Currently apache2 is listening to port 8090, as shown by “sudo netstat -tulpn | grep :8090”.

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 @taimaz,

As explained in the article, you’ll need to edit the port in the Apache’s configuration file :

Listen 80


Listen 81

Having said that, once you do, you’ll need to restart apache and actually enable traffic on that port. To allow all incoming connections on port 81 run these commands:

sudo iptables -A INPUT -p tcp --dport 81 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT.

sudo iptables -A OUTPUT -p tcp --sport 81 -m conntrack --ctstate ESTABLISHED -j ACCEPT.