Express http only working with localhost but not with external ip http connection - node.js

Tried to avoid the listen IP only on the '127.0.0.1', so the listen port 8000 is also bind with the '0.0.0.0'. But external http clients still not able to get the http connection setup. Also tried tcpdump, the client SYN can reach to the node server, but not any response from the node.js http server... this caused the issue. Really appreciate your assistance!
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 1650/node
tcp 0 0 127.0.0.1:56064 127.0.0.1:27017 ESTABLISHED 1650/node
tcp 0 0 127.0.0.1:56062 127.0.0.1:27017 ESTABLISHED 1650/node
tcp 0 0 127.0.0.1:56065 127.0.0.1:27017 ESTABLISHED 1650/node
tcp 0 0 127.0.0.1:56063 127.0.0.1:27017 ESTABLISHED 1650/node
tcp 0 0 127.0.0.1:56061 127.0.0.1:27017 ESTABLISHED 1650/node

Related

Why can't I talk to a service on tcp/3000 on my CentOS VPS

I'm trying to run a second web service on my VPS at port 3000.
On the VPS I run:
# php -S myhost.com:3000
and then in a browser, navigate to http://myhost.com:3000 but the browser times out and the service logs/outputs nothing.
If I run the service on port 80 (i.e., php -S myhost.com:80 and navigate to http://myhost.com), it works.
So firewall. Except that:
[root#spinal ~]# firewall-cmd --list-ports
3887/tcp 3000/tcp
(the 3887 is another service, which is working correctly.) And I rebooted the VPS after setting up port 3000 in the firewall. I reckon the service is listening correctly because:
[root#spinal ~]# netstat -tupl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:imap 0.0.0.0:* LISTEN 1907/dovecot
tcp 0 0 0.0.0.0:ciphire-data 0.0.0.0:* LISTEN 1876/sshd
tcp 0 0 0.0.0.0:http 0.0.0.0:* LISTEN 1903/nginx: master
tcp 0 0 0.0.0.0:urd 0.0.0.0:* LISTEN 2004/master
tcp 0 0 myhost.com:hbci 0.0.0.0:* LISTEN 2206/php
tcp 0 0 localhost.loca:postgres 0.0.0.0:* LISTEN 1908/postgres
tcp 0 0 0.0.0.0:smtp 0.0.0.0:* LISTEN 2004/master
tcp 0 0 0.0.0.0:https 0.0.0.0:* LISTEN 1903/nginx: master
tcp 0 0 0.0.0.0:imaps 0.0.0.0:* LISTEN 1907/dovecot
tcp 0 0 localhost.lo:cslistener 0.0.0.0:* LISTEN 1878/php-fpm: maste
tcp6 0 0 [::]:imap [::]:* LISTEN 1907/dovecot
tcp6 0 0 [::]:ciphire-data [::]:* LISTEN 1876/sshd
tcp6 0 0 [::]:urd [::]:* LISTEN 2004/master
tcp6 0 0 [::]:smtp [::]:* LISTEN 2004/master
tcp6 0 0 [::]:imaps [::]:* LISTEN 1907/dovecot
I can however connect locally. This works, when run on the VPS:
$ curl http://myhost.com:3000
so that again points at the firewall. But disabling the firewall doesn't help:
# systemctl stop firewalld
so it could be a DNS problem: my browser and the VPS differ on what myhost.com resolves-to. Except that, as mentioned above, switching to port 80 solves the problem. So it's something to do with coming-in on port 3000, from outside. But not firewalld.
The question at Can't reach nodejs on port 3000 from external on CentOS 7 is close to mine, but isn't conclusively answered.
I feel pretty stupid. It was a firewall; not on the VPS, but on my local network. When I tried it on a machine that doesn't go through my local network, it worked. I hope my public confession helps someone else.

Eth0 used for incoming and eth1 used outgoing connections NGINX configuration?

I'm using AWS instance and I have two ENI eth0 (192.168.1.100) and eth1 (192.168.1.200), usage of the ETH0 network interface for accepting the incoming connections from clients to NGINX(TCP) and an ETH1 network interface for outgoing connections from NGINX to destination( another instance TCP connection). Is it possible to do that?
As far as I know, yes, it's possible:
proxy_bind 192.168.1.200;
Documentation
#Alexander, Thanks. Its working fine with configuration below,
upstream my_tcp_connect {
server 192.168.1.300:9000;
zone tcp_mem 512k;
}
server {
tcp_nodelay on;
listen 9000 backlog=409600 so_keepalive=30m::10 reuseport;
proxy_pass my_tcp_connect;
proxy_connect_timeout 5s;
proxy_buffer_size 512k;
error_log /var/log/nginx/tcp_error.log info; # nginScript debug logging
proxy_bind 192.168.200;
}
I found some connections established from the NGINX instance,
tcp 0 0 192.168.200:59396 192.168.300:9000 ESTABLISHED 3046/nginx: worker
tcp 0 0 192.168.200:58680 192.168.300:9000 ESTABLISHED 3049/nginx: worker
tcp 0 0 192.168.100:9000 192.30.40.14:53110 ESTABLISHED 3048/nginx: worker
tcp 0 0 192.168.100:9000 192.30.40.14:54924 ESTABLISHED 3049/nginx: worker
TCP Connection instance:
tcp 0 0 192.168.1.300:9000 192.168.200:58632 ESTABLISHED 1997/tcp_connect
tcp 0 0 192.168.1.300:9000 192.168.200:59160 ESTABLISHED 1997/tcp_connect
tcp 0 0 192.168.1.300:9000 192.168.200:59360 ESTABLISHED 1997/tcp_connect
tcp 0 0 192.168.1.300:9000 192.168.200:59298 ESTABLISHED 1997/tcp_connect

All of a sudden -- tcp connect (localhost:5432): connection refused - :econnrefused

For a few months all has been ok, but now I have a lot of:
mix phoenix.server
[error] Postgrex.Protocol (#PID<0.302.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
[error] Postgrex.Protocol (#PID<0.303.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
on localhost.
But:
Postgresql is running
Its config is the same
The config of my phoenix/elixir application is the same too.
systemctl status postgresql shows everything is ok
nothing bad in the log
I can connect to Pg via Pg GUI tool
What's the matter?
$ netstat -tulnp
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp6 0 0 ::1:5432 :::* LISTEN -
udp 0 0 192.168.1.37:68 0.0.0.0:* -
udp 0 0 0.0.0.0:5353 0.0.0.0:* 25117/libpepflashpl
udp6 0 0 :::5353 :::* 25117/libpepflashpl

Galssfish install on CentOS not binding ipv4 port

After installing Glassfish on a CentOS only unziping the zip archive, my server doesn't not bind on ipv4.
With
netstat -tnlup
I've got the result :
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 5278/mysqld
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 4621/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 4825/master
tcp 0 0 :::8686 :::* LISTEN 14659/java
tcp 0 0 :::4848 :::* LISTEN 14659/java
tcp 0 0 :::8080 :::* LISTEN 14659/java
tcp 0 0 :::3700 :::* LISTEN 14659/java
tcp 0 0 :::8181 :::* LISTEN 14659/java
tcp 0 0 :::22 :::* LISTEN 4621/sshd
tcp 0 0 ::1:25 :::* LISTEN 4825/master
tcp 0 0 :::7676 :::* LISTEN 14659/java
udp 0 0 0.0.0.0:68 0.0.0.0:* 1168/dhclient
How can I force glassfish listen on ipv4 addresses too ?
You may find Glassfish is bound to IPv4 (and IPv6) but is being blocked by the iptables firewall settings:
As root:
/etc/init.d/iptables stop
Then try accessing Glassfish via IPv4. If that works then you can re-enable iptables and set the appropriate rules for your environment.
That CentOS isn't showing ports bound on IPv4 when they are also bound on IPv6 looks like a bug to me (2.6.32-358.23.2.el6.x86_64).
I just had this same problem. Not sure yet what triggered the issue, as I have two other servers with the same software that don't show this issue.
In my case, I was able to fix it by adding this environment variable:
export _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true"
Once I restarted Java with this variable, it bound to IPv4, but not v6. I'm curious as to why it's not binding to both.

Linux Centos 6 Some how filtered port 80 + broke Apache 2

I have magically been able to break port 80 / Apache server when following a guide to install PHPMyAdmin (http://www.krizna.com/centos/installing-apache2-mysql-server-php-centos-6-lamp/#apache)
Prior to me to starting the guide, Apache 2 was working for me (was able to view pages and see the default blue one)
I followed the guide down to Step 4 under "PHP installation" and went to check the page and I was getting the following error (note: I skipped Mysql installation since I have it already installed and "Testing your page" in the Apache section since I had it working prior).
ERROR
The requested URL could not be retrieved
The following error was encountered while trying to retrieve the URL: http://`192.168.141.22`/
Read Error
The system returned: (104) Connection reset by peer
An error condition occurred while reading data from the network. Please retry your request.
Your cache administrator is webmaster.
Generated Wed, 03 Jul 2013 19:04:56 GMT by tx22rrpep4da (hpm/3.0.55)
I tried to uninstall (yum erase) httpd and php and re-install and no success.
I did an nmap and it shows 80/tcp filtered http.
I even disabled/stopped IP tables incase that was the issue, no luck. I have other things like TS3 running on other ports fine.
Restarted the dedicated server.
netstat -tulpn
te PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 25896/httpd
tcp 0 0 0.0.0.0:30033 0.0.0.0:* LISTEN 2967/./ts3server_li
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 2736/named
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2798/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2873/master
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 2736/named
tcp 0 0 0.0.0.0:10011 0.0.0.0:* LISTEN 2967/./ts3server_li
tcp 0 0 ::1:53 :::* LISTEN 2736/named
tcp 0 0 :::22 :::* LISTEN 2798/sshd
tcp 0 0 ::1:953 :::* LISTEN 2736/named
udp 0 0 0.0.0.0:9987 0.0.0.0:* 2967/./ts3server_li
udp 0 0 127.0.0.1:53 0.0.0.0:* 2736/named
udp 0 0 ::1:53 :::* 2736/named
I had a few other people test the IP in case it was just my connection but they all got the same as well (IP: 192.168.141.22 )
Really hoping I can get this fixed with out doing something over the top like wiping and re-installing centos 6.
The netstat command is showing that Apache is in-deed listening on the following IP & port:
0 0.0.0.0:80
If you want reach Apache in 192... ip, then you need to edit one of the .conf files that has the "Listen" directive(normally in /etc/httpd/conf.d/ports.conf or the main .conf file) and either put in the ip or remove all ips so Apache can listen on all interfaces available in the machine.

Resources