Question

UFW blocking port 8001 until I login to ubuntu

Ubuntu Desktop 16.04 LTS, running on Hyper-V on windows 10 pro x64 I have two wordpress sites, one is on port 80 with server_name directive pointing to root The other is running on port 8001. I don’t remember why I configured it this way but I’m ok with changing it. The problem seems to be that even though I have all the ports open I have to login to ubuntu before the firewall rule kicks in . My port 80 site works fine but the 8001 gives chrome a sad page icon until after the login.

[02/11/2017 12:25:50 AM] Status: Enabled
[02/11/2017 12:25:37 AM] Status: Disabled
[02/11/2017 12:25:20 AM] Status: Enabled
[02/10/2017 07:35:52 AM] Appending new rules: ufw allow in 81 > Skipping adding existing rule | Skipping adding existing rule (v6)
[02/10/2017 07:35:52 AM] Appending new rules: ufw allow in 8001 > Skipping adding existing rule | Skipping adding existing rule (v6)
[02/10/2017 07:35:52 AM] Appending new rules: ufw allow in 81 > Rule added | Rule added (v6)
[02/10/2017 07:35:52 AM] Appending new rules: ufw allow in 8001 > Rule added | Rule added (v6)
[02/10/2017 07:35:52 AM] Deleting previous rules: 3 ufw --force delete 3 > Rule deleted
[02/10/2017 07:35:52 AM] Deleting previous rules: 6 ufw --force delete 6 > Rule deleted (v6)
[02/10/2017 07:35:51 AM] Status: Enabled
[02/10/2017 07:35:50 AM] Changing profile: Public

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

@iburnthings

What I would recommend doing, just to make sure we get the correct setup, is running

ufw disable

Then

ufw reset

The above stops ufw and then resets all rules. With a clean slate, we setup our default policies first.

ufw default deny incoming \
&& ufw default allow outgoing

With those rules in place, we then add the rules we need to work for whatever our purposes are. To start, I recommend allowing SSH in first.

ufw allow 22/tcp

We can then allow application-specific ports, such as 80, 443, 8001, etc. I’ll start with those three.

ufw allow 80/tcp \
&& ufw allow 443/tcp \
&& ufw allow 8001/tcp

We could also run just one command (copy and paste directly)

ufw disable \
&& ufw reset \
&& ufw default deny incoming \
&& ufw default allow outgoing \
&& ufw allow 22/tcp \
&& ufw allow 80/tcp \
&& ufw allow 443/tcp \
&& ufw allow 8001/tcp

Now, if you need to add any other ports, now’s the time to go ahead and add them. If nothing more needs to be added, we can then run

ufw enable

When prompted to confirm, type y, hit enter, and ufw is active once again.

The benefit to the above is outgoing connections are always allowed, though only the ports you define are permitted to connect (i.e. incoming).

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel