I have nginx running on port 81. I can telnet using telnet 127.0.0.1 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?
You have server name as
This is wrong !!!!!
Put any name not number like
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
where X.X gets replaced with numbers
or
If you want to serve all the request , simply put
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 127.0.0.1
Disable firewall
Check the listening address for port 81
I had the same problem a few months ago when I was trying to run ngnix on my Ubuntu system and access the services from another Windows system. I was not able to access any port service like http://127.0.0.1/8000 but after some time, I fixed this by turning off the firewall on my Ubuntu system.
Command to turn off the firewall:
You can also check the status of your firewall first:
Tips which helped me: A.)Port forward B.)Set the public IP as server_name These steps worked for me especially tip A.)