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 -
Related
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
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
I have lost connection to Cassandra server and I am not able to restore it back.
When I run: sudo service cassandra status I can see service is running:
● cassandra.service - LSB: distributed storage system for structured data
Loaded: loaded (/etc/init.d/cassandra; generated; vendor preset: enabled)
Active: active (exited) since Fri 2018-04-27 13:06:21 UTC; 4min 5s ago
Docs: man:systemd-sysv-generator(8)
Process: 18479 ExecStop=/etc/init.d/cassandra stop (code=exited, status=0/SUCCESS)
Process: 18539 ExecStart=/etc/init.d/cassandra start (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 4915)
CGroup: /system.slice/cassandra.service
Apr 27 13:06:21 serveur-1 systemd[1]: Starting LSB: distributed storage system for structured data...
Apr 27 13:06:21 serveur-1 systemd[1]: Started LSB: distributed storage system for structured data.
But When I run > cqlsh, I got the following:
Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})
Deleting content of directory /var/lib/cassandra/commitlog and restarting cassandra fixed my issue !
Check that Cassandra really accepts connections through loopback interface.
See what's in your cassandra.yaml under listen_address and listen_interface property
# cat /etc/cassandra/cassandra.yaml | grep listen
...
listen_address: 172.17.0.2
...
If you see a non local address, it might happen that cqlsh needs to connect through another interface to your Cassandra instance. Try this command (by replacing the IP with the same IP in configuration:
# cqlsh 172.17.0.2
You can check which hosts are allowed co access your Cassandra service using the following command
# netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:7199 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:9042 0.0.0.0:* LISTEN
tcp 0 0 localhost:38899 0.0.0.0:* LISTEN
tcp 0 0 20f1802:afs3-fileserver 0.0.0.0:* LISTEN
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node Path
0.0.0.0 means that my Cassandra instance allows connection from both loopback and ethernet interface.
Delete all content from commitlog and it will work.
I'm using a Linux VM (Ubuntu 15.10) to spin up a Postgres Database, and as far as I can tell, everything should be configured right.
My firewall is disabled:
user#UBUNTUMACHINE:~$ sudo ufw status numbered Status: inactive
But it's only listening on port 22
user#UBUNTUMACHINE:~$ netstat -an | grep "LISTEN "
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
If I enable the firewall, and tell it to listen to 5432, it shows up in the rules:
user#UBUNTUMACHINE:~$ sudo ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip
To Action From
-- ------ ----
22 ALLOW IN Anywhere
22/tcp ALLOW IN Anywhere
5432/tcp ALLOW IN Anywhere
5432 ALLOW IN Anywhere
22 (v6) ALLOW IN Anywhere (v6)
22/tcp (v6) ALLOW IN Anywhere (v6)
5432/tcp (v6) ALLOW IN Anywhere (v6)
5432 (v6) ALLOW IN Anywhere (v6)
But I get the same results as above for netstat.
As far as I can tell from researching the issue, I have the correct values in my postgresql.conf file:
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
and I've tried both IP ranges and specific IPs as trusted in the pg_hba.conf file.
# Database administrative login by Unix domain socket
local all postgres ident sameuser
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
host all all 10.0.0.0/255 trust
host all all 10.11.0.0/255 trust
host all all 0.0.0.0/0 trust
Lastly, Postgres is running, per
user#UBUNTUMACHINE:~$ sudo service postgresql status
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Wed 2017-03-08 11:09:57 CST; 57min ago
Process: 787 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 787 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/postgresql.service
Mar 08 11:09:57 UBUNTUMACHINEsystemd[1]: Starting PostgreSQL RDBMS...
Mar 08 11:09:57 UBUNTUMACHINEsystemd[1]: Started PostgreSQL RDBMS.
Mar 08 11:32:21 UBUNTUMACHINEsystemd[1]: Started PostgreSQL RDBMS.
Mar 08 11:32:26 UBUNTUMACHINEsystemd[1]: Started PostgreSQL RDBMS.
The log is telling me invalid CIDR mask in address 10.0.0.0/255
:: 255 might be larger than 32
Postgres refuses to start, because it refuses the netmask /255 which islarger than the possible number of bits in the (32 bits) IP-address. You could consider this to be a bit picky for the .hba parser, but it could also be considerered a configuration error.
In any case: replace the /255 by something sensible, like /24 (or /16, since you have two of these entries) And: replace the trust by something more safe, after it appears to work.
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?