Node web application was started in Linux, but web service access prompts no server data - linux

Recently, I rented a Linux server, and on that, I developed a Node.js web program. I have opened the port, but I still can't access this web service.
iptables setting is below:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
iptables status is below:
[root#VAM_60_90_centos firewalld]# systemctl status iptables.service
* iptables.service - IPv4 firewall with iptables
Loaded: loaded (/user/lib/systemd/system/iptables.service; enabled; vendor preset: disabled)
Active: active (exited) since Thu 2017-03-02 22:41:10 CST; 11min ago
Main PID: 22884 (code=exited, status=0/SUCCESS)
Mar 02 22:41:10 VM_60_90_centos systemd[1]: Starting IPv4 firewall with iptables...
Mar 02 22:41:10 VM_60_90_centos iptables.init[22884]: iptables: Applying firewall rules: [ OK ]
Mar 02 22:41:10 VM_60_90_centos systemd[1]: Started IPv4 firewall with iptables.
What can I do to fix this?

Related

Why I can't connect port 8080 using node.js in CentOS?

I created web server using node.js in CentOS 8.
But It doesn't work.
This is my node.js web server.
const http = require('http');
const hostname = '0.0.0.0';
const port = '8080';
httpd = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('Hello World!');
});
httpd.listen(port, hostname, function(){
console.log('Server Start');
});
I sent ping to centos for port 22 and 8080.
I couldn't receive response for only port 8080.
C:\Users\user>tcping -p 22 <centOS IP>
Probing <centOS IP>:22/tcp - Port is open - time=14.019ms
Probing <centOS IP>:22/tcp - Port is open - time=13.159ms
Probing <centOS IP>:22/tcp - Port is open - time=8.601ms
Probing <centOS IP>:22/tcp - Port is open - time=9.896ms
C:\Users\user>tcping -p 8080 <centOS IP>
Probing <centOS IP>:8080/tcp - No response - time=2010.980ms
Probing <centOS IP>:8080/tcp - No response - time=2008.277ms
Probing <centOS IP>:8080/tcp - No response - time=2008.509ms
Probing <centOS IP>:8080/tcp - No response - time=2000.949ms`
I cheked below info.
(I checked listening port 8080)
(I turned off the firewalld, iptables...)
<Linux>
[opc#instance-20220607-1056 webTest]$ netstat -tnlp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9003 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
.
.
[opc#instance-20220607-1056 webTest]$ sudo service iptables status
Redirecting to /bin/systemctl status iptables.service
Unit iptables.service could not be found.
[opc#instance-20220607-1056 webTest]$ sudo systemctl status nftables
nftables.service - Netfilter Tables
Loaded: loaded (/usr/lib/systemd/system/nftables.service; disabled; vendor p>
Active: inactive (dead)
Docs: man:nft(8)
lines 1-4/4 (END)
[opc#instance-20220607-1056 webTest]$ sudo systemctl status firewalld
firewalld.service
Loaded: masked (Reason: Unit firewalld.service is masked.)
Active: inactive (dead)
Jan 05 17:49:52 instance-20220607-1056 systemd[1]: Starting firewalld - dynamic firewall daemon...
Jan 05 17:49:54 instance-20220607-1056 systemd[1]: Started firewalld - dynamic firewall daemon.
Jan 05 17:49:54 instance-20220607-1056 firewalld[1480]: WARNING: AllowZoneDrifting is enabled. This is consi>
Jan 05 20:38:06 instance-20220607-1056 systemd[1]: Stopping firewalld - dynamic firewall daemon...
Jan 05 20:38:10 instance-20220607-1056 systemd[1]: firewalld.service: Succeeded.
Jan 05 20:38:10 instance-20220607-1056 systemd[1]: Stopped firewalld - dynamic firewall daemon.
[opc#instance-20220607-1056 webTest]$ sudo lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: OracleServer
Description: Oracle Linux Server release 8.7
Release: 8.7
Codename: n/a
What more should I check?
Thank you for your answer.
This issues occurred for Oracle cloud setting
I solved this problem by referring to the link below.
link

pgadmin4 can't connect to postgres running over Rocky Linux

The postgres is running on Rocky Linux 8.5:
sudo systemctl status postgresql-14
● postgresql-14.service - PostgreSQL 14 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-14.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/postgresql-14.service.d
└─override.conf
Active: active (running) since Thu 2022-03-10 04:31:09 GMT; 16min ago
Docs: https://www.postgresql.org/docs/14/static/
Process: 67527 ExecStartPre=/usr/pgsql-14/bin/postgresql-14-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 67534 (postmaster)
Tasks: 8 (limit: 101066)
Memory: 18.3M
CGroup: /system.slice/postgresql-14.service
├─67534 /usr/pgsql-14/bin/postmaster -D /mnt/data/db-rocky-primary/data
├─67536 postgres: logger
├─67538 postgres: checkpointer
├─67539 postgres: background writer
├─67540 postgres: walwriter
├─67541 postgres: autovacuum launcher
├─67542 postgres: stats collector
└─67543 postgres: logical replication launcher
Mar 10 04:31:08 db-primary-rocky systemd[1]: Starting PostgreSQL 14 database server...
Mar 10 04:31:09 db-primary-rocky postmaster[67534]: 2022-03-10 04:31:09.590 GMT [67534] LOG: redirecting log output to logging collector process
Mar 10 04:31:09 db-primary-rocky postmaster[67534]: 2022-03-10 04:31:09.590 GMT [67534] HINT: Future log output will appear in directory "log".
Mar 10 04:31:09 db-primary-rocky systemd[1]: Started PostgreSQL 14 database server.
I can connect to it with no issues when on the box:
psql
psql (14.2)
Type "help" for help.
postgres=# \conninfo
You are connected to database "postgres" as user "postgres" via socket in "/var/run/postgresql" at port "5432".
I have added this to the pg_hba.conf file:
host all all 192.168.1.0/24 trust
I have also changed the following in the postgresql.conf file and restarted the server:
listen_addresses = '*'
why I can't connect to it via pgadmin4? I am sitting in the 192.168.1.0/24 network and the PostgreSQL running in 192.168.1.0/24 network.
Both networks can ping each other. The pgadmin4 gives connection refused error. I am not sure why?
what am I missing?
thanks
As per #Nic3500 comment, that's how I fixed it:
check if postgres is listening on the designated port:
sudo netstat -nltp
Now check if firewall is enabled:
systemctl status firewalld
OR
sudo firewall-cmd --state
if the service is active and running then simply do the following:
sudo firewall-cmd --add-service=postgresql
Make the settings permanent:
sudo firewall-cmd --runtime-to-permanent
Now you can connect with no issues

SSH File Transfer from Mint to RPi works not bidirectional

I am new to Linux and RPi. I want to transfer a file from my Pi to my PC.
With ...
scp hello pi#192.168.1.101:/home/pi
.. I am able to transfer my file "hell" to my Pi.
But when I try to send the file "elle" with ...
scp elle mirco#192.168.1.104:/home/mirco
i get
ssh: connect to host 192.168.1.104 port 22: Connection timed out lost connection
I read the ssh service status from the pi and my Computer:
Pi:
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; disabled; vendor preset: enabled)
Active: active (running) since Wed 2020-04-08 14:38:18 CEST; 6s ago
Docs: man:sshd(8)
man:sshd_config(5)
Process: 14004 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 14006 (sshd)
Tasks: 1 (limit: 4915)
Memory: 804.0K
CGroup: /system.slice/ssh.service
└─14006 /usr/sbin/sshd -D
Apr 08 14:38:18 raspberrypi systemd[1]: Starting OpenBSD Secure Shell server...
Apr 08 14:38:18 raspberrypi sshd[14006]: Server listening on 0.0.0.0 port 22.
Apr 08 14:38:18 raspberrypi sshd[14006]: Server listening on :: port 22.
Apr 08 14:38:18 raspberrypi systemd[1]: Started OpenBSD Secure Shell server.
My Computer:
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-04-08 14:52:26 CEST; 6min ago
Process: 9224 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
Process: 9216 ExecReload=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Process: 8934 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 8935 (sshd)
Tasks: 1 (limit: 4578)
CGroup: /system.slice/ssh.service
└─8935 /usr/sbin/sshd -D
Apr 08 14:52:26 ComputerMirco systemd[1]: Stopping OpenBSD Secure Shell server...
Apr 08 14:52:26 ComputerMirco systemd[1]: Stopped OpenBSD Secure Shell server.
Apr 08 14:52:26 ComputerMirco sshd[8935]: Server listening on 0.0.0.0 port 22.
Apr 08 14:52:26 ComputerMirco systemd[1]: Starting OpenBSD Secure Shell server...
Apr 08 14:52:26 ComputerMirco systemd[1]: Started OpenBSD Secure Shell server.
Apr 08 14:58:12 ComputerMirco systemd[1]: Reloading OpenBSD Secure Shell server.
Apr 08 14:58:12 ComputerMirco sshd[8935]: Received SIGHUP; restarting.
Apr 08 14:58:12 ComputerMirco sshd[8935]: Server listening on 0.0.0.0 port 22.
Can someone help me?
Thank you!
Mirco
Am I correct in thinking you're running the second SCP command on your Pi? If so, your Pi isn't authorized to connect to your PC. You can add it's public key to your authorized_keys file and your Pi will be able to connect to your PC.
You could also pull the file in from your Pi. This is safer because you don't really want your Pi to be able to connect to your PC.
SCP copy to host example
scp pi#192.168.1.101:/home/pi/elle /home/mirco
My guess is that your PC doesn't have ssh enabled.
Install openssh-server on your PC using
sudo apt install openssh-server
After installing this, a system service called ssh should have become active.
You can test this using
sudo systemctl status ssh
Your output should look something like this
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-04-08 10:05:07 IST; 13h ago
If it doesn't show active(running), try executing
sudo systemctl enable ssh
If you still are not able to ssh, enable the ssh port through your firewall.
In Ubuntu this can be done by
sudo ufw allow ssh

CentOS 7 + Lighttpd, web server not working altough running

I have installed lighttpdon my new CENOS 7.
When I'm trying to access my IP, it is loading than eventually says that the site can't be reached, (ERR_CONNECTION_TIMED_OUT).
WHen runnig systemctl status lighttpd -l, It looks like the service is up and running.
Any idea?
[root#myvps ~]# systemctl status lighttpd -l
● lighttpd.service - Lightning Fast Webserver With Light System Requirements
Loaded: loaded (/usr/lib/systemd/system/lighttpd.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2020-02-11 09:50:53 CET; 19min ago
Main PID: 7559 (lighttpd)
CGroup: /system.slice/lighttpd.service
└─7559 /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
Feb 11 09:50:53 myvps.mydomain.net systemd[1]: Stopped Lightning Fast Webserver With Light System Requirements.
Feb 11 09:50:53 myvps.mydomain.net systemd[1]: Started Lightning Fast Webserver With Light System Requirements.
Feb 11 09:50:53 myvps.mydomain.net lighttpd[7559]: 2020-02-11 09:50:53: (network.c.162) warning: please use server.use-ipv6 only for hostnames, not without server.bind / empty address; your config will break if the kernel default for IPV6_V6ONLY changes
Feb 11 09:50:53 myvps.mydomain.net lighttpd[7559]: 2020-02-11 09:50:53: (server.c.1437) can't have more connections than fds/2: 1024 1024
[root#myvps ~]#
Solved by running
firewall-cmd --permanent --add-service=http
success
[root#myvps~]# firewall-cmd --reload
success
found it somewhere on the web.

How to make Mongodb 27017 port available on Ubuntu

After installing and starting mongodb on Google Ubuntu instance I can verify that 'mongodb' is running with: sudo systemctl status mongodb:
● mongodb.service - LSB: An object/document-oriented database
Loaded: loaded (/etc/init.d/mongodb; generated; vendor preset: enabled)
Active: active (running) since Mon 2017-02-27 19:41:17 UTC; 57min ago
Docs: man:systemd-sysv-generator(8)
Tasks: 13 (limit: 4915)
Memory: 71.7M
CPU: 14.520s
CGroup: /system.slice/mongodb.service
└─1914 /usr/bin/mongod --config /etc/mongodb.conf
Feb 27 19:41:15 instance-1 systemd[1]: Starting LSB: An object/document-oriented database...
Feb 27 19:41:16 instance-1 mongodb[1827]: * Starting database mongodb
Feb 27 19:41:17 instance-1 mongodb[1827]: ...done.
Feb 27 19:41:17 instance-1 systemd[1]: Started LSB: An object/document-oriented database.
It all looks good. But by some reason another application running on the same machine is not able to connect to the what-seems-to-be-running-properly mongodb.
Running nmap 127.0.0.1 returns:
PORT STATE SERVICE
22/tcp open ssh
631/tcp open ipp
There is no mongodb's port # 27017 listed there as *open*.
Interesting that the firewall is disabled. How can I assure themongodbport27017` is open and available to other applications?
nmap scan all common port, mongodb use port 27017 by default which is not listed in default nmap default port scan. On the other hand, you can specify the port manually :
nmap -p 27017 127.0.0.1
You will get :
PORT STATE SERVICE
27017/tcp open unknown
If you see STATE close, this means mongodb is not running and then you should begin to worry about it
Or as suggested by #Dimitri using netstat such as :
netstat -tulpn
which gives :
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN -

Resources