[Solved] Ubuntu refusing connection on port 80

I was getting this issue that I was not able to connect to port 80 on ubuntu server. Same virtual network settings were being used with a different instance but everything was working fine on it. I figured the problem is in the instance settings.

I searched through the web but nothing was working. So I decided to go through the server log. I know I should have done this first.

I found these lines in the syslog file:

The issue was in iptables and I needed to flush it

I ran the command highlighted in the the image above

/usr/sbin/netfilter-persistent flush 

It gave following output

I tried to to connect to the port 80 and the default nginx page loaded in browser.

Problem solved.

But doing this messed up my OpenVPN server. OpenVPN client was connecting but internet was not accessible.

So I rebooted the system to see if it fixes the problem.

It did fixed OpenVPN.

But again port 80 was inaccessible.

I checked the status of ufw and it was disable. I had enabled it before I rebooted. Iptable rules were all reset. I googled why ufw was disabled and found iptables-persistent conflicts with ufw.

I disabled iptables-persistent using this command

sudo systemctl disable netfilter-persistent

I rebooted the system again and this time ufw stayed enabled and I was able to access the port 80 and also OpenVPN was working as intended.