Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm setting up ufw for the first time. Using Ubuntu 10.04 LTS on an OpenVZ VPN and have the following rules:

sudo ufw allow 22/tcp
sudo ufw allow 25/tcp
sudo ufw allow 53
sudo ufw allow 80
sudo ufw allow 443
sudo ufw default deny

SSH and everything else works fine, and I can access static content on nginx. However when I visit a PHP page, it takes ages before giving a 504 Gateway Time-out page. I'm using php5-fpm

I've tried a number of rules including the following:

allow from to port 9000
allow from port 9000 to port 9000
allow 9000
allow from to

But none of them fix the problem. As soon as I turn off the firewall, everything works fine. Php5-fpm is definitely running and using port 9000.

Any help appreciated, thanks! I'll post back if I work it out.

Additional config:

share|improve this question

Right.. I think that a lot of the confusion is because of UFW, so I'll make the recommendation that you stop using it, and spend some time learning how iptables itself works. It's much more common to use iptables directly, instead of a wrapper around it.

In the meantime.


allow from
allow in on lo0
allow out on lo0
share|improve this answer
I can't vote up as under 15 reputation, but thanks for your help. This did not work, the problem seems to be OpenVZ related issues with iptables. I solved the problem by learning all about iptables and not using ufw. OpenVZ is very picky about what iptables commands can be used. – John Jan 21 '11 at 14:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.