Z Hu
Z Hu

Reputation: 1015

oraclecloud ubuntu20 Connection refused

I have a strange problem, I installed various services directly on the server, but I can't access them (only happens on OracleCloud's server, I have never encountered this problem with other Clouds). The following is the introduction of my test, start a new instance (ARM Ubuntu20), install nginx

can access it normally through localhost

$ curl localhost:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

abnormal access through the network

$ curl 138.*.*.50:80 

curl: (7) Failed to connect to 138.*.*.50 port 80: No route to host

stop the nginx service. Install docker

start the nginx container, map port 80 to port 80 of the host

$ docker run --name nginx_test -p 80:80 -d nginx

and both localhost and the network can access it

root@instance-20220222-2204:/etc/nginx# curl localhost:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
root@instance-20220222-2204:/etc/nginx# curl 138.*.*.50:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

The following is a screenshot of my operation, during which I did not do anything to modify the firewall and security group

nginx

docker-nginx

Upvotes: 2

Views: 986

Answers (2)

Sinan Eldem
Sinan Eldem

Reputation: 5728

ufw disable

iptables -F

Generallay solves this issue.

If you have no connectivity after dropping everything with the -F, then run the following:

sudo nano /etc/default/ufw –> make sure that IPV6=yes

iptables -P INPUT ACCEPT;
sudo ufw reset;
sudo ufw disable;
sudo ufw default deny incoming;
sudo ufw default allow outgoing;
sudo ufw allow ssh;
sudo ufw allow http;
sudo ufw allow https;
sudo ufw enable;
sudo ufw status;

Make sure its OK.

You may add your posrt by manually if needed:

sudo ufw allow PORTNUMBER
sudo ufw allow 22

add by range:

sudo ufw allow 39000:39010/tcp

Upvotes: 0

Z Hu
Z Hu

Reputation: 1015

Empty rules solved my problem

ufw disable

iptables -F

Upvotes: 6

Related Questions