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

I have nginx running on port 81. I can telnet using telnet 81 and everything is fine.

But when I try to telnet to my machine from my Mac (an external IP address), I just get this error:

telnet: connect to address 109.123.x.x: Connection refused
telnet: Unable to connect to remote host

Here is my /etc/nginx/sites-available/default file:

server {
        listen   81; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default ipv6only=on; ## listen for ipv6

        root /usr/share/nginx/www;
        index index.html index.htm;

        # Make site accessible from http://localhost/
        server_name 109.123.x.x;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to index.html
                try_files $uri $uri/ /index.html;

I've opened Ubuntu Firewall (ufw) to allow port 81.

I'm totally stuck now.

Anyone have any ideas?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

You have server name as

server_name 109.123.x.x;

This is wrong !!!!!

Put any name not number like

server_name mywebsite.home;

and put mywebsite.home as the IP of the nginx server in your host file(/etc/hosts) i.e in your mac like in format

109.123.X.X mywebsite.home

where X.X gets replaced with numbers


If you want to serve all the request , simply put

server_name _;

If that does not solve the things , check below

It's either your firewall i.e iptables blocking your traffic or you have your nginx listening only at localhost i.e

Disable firewall

sudo ufw disable

Check the listening address for port 81

sudo netstat -tulpn
share|improve this answer
I switched to port 8080 and it's working now. Might be something to do with a priviliged port or maybe my 3G connection blocks port 81. Anyway, it's working now. Many thanks for your help. –  Eamorr Feb 18 '12 at 18:37
If its an instance in the cloud like rackspace or AWS, check your Security Groups. By default port 22 and 80 are the only ones usually open. –  radtek Oct 28 '14 at 11:57

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.