mlflow models serve -m mlflow_model - mlflow

I have a problem with serve MLflow. When I execute this code :
mlflow models serve -m mlflow_model/
I have this error:
2022/07/24 14:11:15 INFO mlflow.pyfunc.backend: === Running command 'source /opt/anaconda3/bin/../etc/profile.d/conda.sh && conda activate mlflow-a116dac3ec81be8ec538fa60f4402b7d813c2192 1>&2 && exec gunicorn --timeout=60 -b 127.0.0.1:5000 -w 1 ${GUNICORN_CMD_ARGS} -- mlflow.pyfunc.scoring_server.wsgi:app'
[2022-07-24 14:11:16 +0200] [7534] [INFO] Starting gunicorn 20.1.0
[2022-07-24 14:11:16 +0200] [7534] [ERROR] Connection in use: ('127.0.0.1', 5000)
[2022-07-24 14:11:16 +0200] [7534] [ERROR] Retrying in 1 second.
[2022-07-24 14:11:17 +0200] [7534] [ERROR] Connection in use: ('127.0.0.1', 5000)
[2022-07-24 14:11:17 +0200] [7534] [ERROR] Retrying in 1 second.
[2022-07-24 14:11:18 +0200] [7534] [ERROR] Connection in use: ('127.0.0.1', 5000)
[2022-07-24 14:11:18 +0200] [7534] [ERROR] Retrying in 1 second.
[2022-07-24 14:11:19 +0200] [7534] [ERROR] Connection in use: ('127.0.0.1', 5000)
[2022-07-24 14:11:19 +0200] [7534] [ERROR] Retrying in 1 second.
[2022-07-24 14:11:20 +0200] [7534] [ERROR] Connection in use: ('127.0.0.1', 5000)
[2022-07-24 14:11:20 +0200] [7534] [ERROR] Retrying in 1 second.
[2022-07-24 14:11:21 +0200] [7534] [ERROR] Can't connect to ('127.0.0.1', 5000)
Traceback (most recent call last):
File "/opt/anaconda3/bin/mlflow", line 8, in <module>
sys.exit(cli())
File "/opt/anaconda3/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "/opt/anaconda3/lib/python3.9/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/opt/anaconda3/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/opt/anaconda3/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/opt/anaconda3/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/opt/anaconda3/lib/python3.9/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/opt/anaconda3/lib/python3.9/site-packages/mlflow/models/cli.py", line 68, in serve
return _get_flavor_backend(
File "/opt/anaconda3/lib/python3.9/site-packages/mlflow/pyfunc/backend.py", line 261, in serve
raise Exception(
Exception: Command 'exec gunicorn --timeout=60 -b 127.0.0.1:5000 -w 1 ${GUNICORN_CMD_ARGS} -- mlflow.pyfunc.scoring_server.wsgi:app' returned non zero return code. Return code = 1
conda.yaml
channels:
defaults
anaconda
dependencies:
python=3.9.12
pip<=22.1.2
pip:
mlflow
cloudpickle==2.0.0
scikit-learn==1.0.2
name: mlflow-env
I have changed the port to 8502 but in vain. I have this message:
[2022-07-26 02:28:06 +0200] [45925] [INFO] Listening at: http://127.0.0.1:8502 (45925)
[2022-07-26 02:28:06 +0200] [45925] [INFO] Using worker: sync
[2022-07-26 02:28:06 +0200] [45933] [INFO] Booting worker with pid: 45933
/opt/anaconda3/envs/mlflow-278b1bb076f93c0a5f2665638173d22fba5482d5/lib/python3.9/site-packages/lightgbm/init.py:40: UserWarning: Starting from version 2.2.1, the library file in distribution wheels for macOS is built by the Apple Clang (Xcode_8.3.3) compiler.
This means that in case of installing LightGBM from PyPI via the pip install lightgbm command, you don't need to install the gcc compiler anymore.
Instead of that, you need to install the OpenMP library, which is required for running LightGBM on the system with the Apple Clang compiler.
You can install the OpenMP library by the following command: brew install libomp.
warnings.warn("Starting from version 2.2.1, the library file in distribution wheels for macOS "
I show you too my ports already used:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
loginwind 170 mohamedads 8u IPv4 0xd7d0f4b08a76d93 0t0 UDP :
ControlCe 435 mohamedads 20u IPv4 0xd7d0f4b08a6a8d3 0t0 UDP :
rapportd 480 mohamedads 3u IPv4 0xd7d0f4b08a76773 0t0 UDP :
rapportd 480 mohamedads 4u IPv4 0xd7d0f4b08a76a83 0t0 UDP :
rapportd 480 mohamedads 7u IPv4 0xd7d0f4b08a78923 0t0 UDP :
identitys 485 mohamedads 26u IPv4 0xd7d0f4b08a629d3 0t0 UDP :
identitys 485 mohamedads 28u IPv4 0xd7d0f4b08a49c33 0t0 UDP :
sharingd 493 mohamedads 4u IPv4 0xd7d0f4b08a42a83 0t0 UDP :
sharingd 493 mohamedads 8u IPv4 0xd7d0f4b08a42463 0t0 UDP :
sharingd 493 mohamedads 9u IPv4 0xd7d0f4b08a42153 0t0 UDP :
sharingd 493 mohamedads 10u IPv4 0xd7d0f4b08a436c3 0t0 UDP :
sharingd 493 mohamedads 14u IPv4 0xd7d0f4b08a76153 0t0 UDP :
sharingd 493 mohamedads 33u IPv4 0xd7d0f4b08a6ca83 0t0 UDP :
sharingd 493 mohamedads 34u IPv4 0xd7d0f4b08a6d0a3 0t0 UDP :
WiFiAgent 511 mohamedads 5u IPv4 0xd7d0f4b08a6f8d3 0t0 UDP :
Dropbox 548 mohamedads 71u IPv4 0xd7d0f4fd5823123 0t0 TCP 192.168.0.14:49185->162.125.6.20:https (ESTABLISHED)
Dropbox 548 mohamedads 107u IPv6 0xd7d0f596050d7c3 0t0 TCP *:17500 (LISTEN)
Dropbox 548 mohamedads 108u IPv4 0xd7d0f4fd4f8d67b 0t0 TCP *:17500 (LISTEN)
Dropbox 548 mohamedads 109u IPv4 0xd7d0f4b08a75b33 0t0 UDP *:17500
Dropbox 548 mohamedads 147u IPv4 0xd7d0f4fd4f8abcb 0t0 TCP localhost:17603 (LISTEN)
Dropbox 548 mohamedads 148u IPv4 0xd7d0f4fd4f8ebcb 0t0 TCP localhost:17600 (LISTEN)
Dropbox 548 mohamedads 155u IPv4 0xd7d0f4fd5825bcb 0t0 TCP 192.168.0.14:65500->162.125.19.9:https (ESTABLISHED)
Dropbox 548 mohamedads 167u IPv4 0xd7d0f4fd582467b 0t0 TCP 192.168.0.14:65483->162.125.19.131:https (ESTABLISHED)
assistant 564 mohamedads 45u IPv4 0xd7d0f4b08a74ef3 0t0 UDP :
com.apple 793 mohamedads 43u IPv6 0xd7d0f596050bbc3 0t0 TCP localhost:65493->localhost:8501 (ESTABLISHED)
Notes 1226 mohamedads 13u IPv4 0xd7d0f4fd582267b 0t0 TCP 192.168.0.14:65232->imap.1and1.fr:imaps (ESTABLISHED)
Notes 1226 mohamedads 14u IPv4 0xd7d0f4fd582267b 0t0 TCP 192.168.0.14:65232->imap.1and1.fr:imaps (ESTABLISHED)
Notes 1226 mohamedads 37u IPv6 0xd7d0f59605052c3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:65084->wo-in-x6d.1e100.net:imaps (ESTABLISHED)
Notes 1226 mohamedads 38u IPv6 0xd7d0f59605052c3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:65084->wo-in-x6d.1e100.net:imaps (ESTABLISHED)
python3.9 1314 mohamedads 5u IPv4 0xd7d0f4fd5808bcb 0t0 TCP localhost:commplex-main (LISTEN)
Google 14186 mohamedads 20u IPv4 0xd7d0f4fd5b41bcb 0t0 TCP 192.168.0.14:65486->192.168.0.17:8009 (ESTABLISHED)
Google 14186 mohamedads 24u IPv4 0xd7d0f4fd582abcb 0t0 TCP localhost:65495->localhost:commplex-link (ESTABLISHED)
Google 14186 mohamedads 27u IPv6 0xd7d0f59605060c3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:49156->[2606:4700::6812:1a91]:https (ESTABLISHED)
Google 14186 mohamedads 30u IPv4 0xd7d0f4fd4f8967b 0t0 TCP 192.168.0.14:49159->249.195.120.34.bc.googleusercontent.com:https (ESTABLISHED)
Google 14186 mohamedads 31u IPv6 0xd7d0f4b08a78c33 0t0 UDP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:55745->par21s22-in-x0a.1e100.net:https
Google 14186 mohamedads 33u IPv6 0xd7d0f5960507cc3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:49158->par10s34-in-x0e.1e100.net:https (ESTABLISHED)
Google 14186 mohamedads 34u IPv4 0xd7d0f4fd4f8e123 0t0 TCP 192.168.0.14:49155->249.195.120.34.bc.googleusercontent.com:https (ESTABLISHED)
Google 14186 mohamedads 35u IPv6 0xd7d0f59605098c3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:65533->[2606:4700:4400::ac40:929e]:https (ESTABLISHED)
Google 14186 mohamedads 37u IPv6 0xd7d0f596050adc3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:49154->par21s05-in-x01.1e100.net:https (ESTABLISHED)
Google 14186 mohamedads 38u IPv4 0xd7d0f4fd581e67b 0t0 TCP 192.168.0.14:49182->server-52-84-174-19.cdg50.r.cloudfront.net:https (ESTABLISHED)
Google 14186 mohamedads 39u IPv6 0xd7d0f5960506ec3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:65507->[2606:4700:20::681a:cf5]:https (ESTABLISHED)
Google 14186 mohamedads 40u IPv4 0xd7d0f4fd583667b 0t0 TCP 192.168.0.14:65506->ec2-52-202-168-65.compute-1.amazonaws.com:https (CLOSED)
Google 14186 mohamedads 41u IPv6 0xd7d0f596050b4c3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:49161->[2600:9000:218d:a000:b:67f0:7600:93a1]:https (ESTABLISHED)
Google 14186 mohamedads 42u IPv6 0xd7d0f5960508ac3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:49160->[2a04:4e42:1d::282]:https (ESTABLISHED)
Google 14186 mohamedads 44u IPv4 0xd7d0f4fd580c123 0t0 TCP 192.168.0.14:65509->sledge-cdg.slb.sfdcsvc.net:https (ESTABLISHED)
Google 14186 mohamedads 45u IPv4 0xd7d0f4fd580b67b 0t0 TCP 192.168.0.14:65508->sledge-cdg.slb.sfdcsvc.net:https (ESTABLISHED)
Google 14186 mohamedads 48u IPv6 0xd7d0f596050e5c3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:65348->wo-in-f188.1e100.net:5228 (ESTABLISHED)
Google 14186 mohamedads 51u IPv4 0xd7d0f4fd581dbcb 0t0 TCP 192.168.0.14:49183->server-52-84-174-118.cdg50.r.cloudfront.net:https (ESTABLISHED)
Google 14186 mohamedads 53u IPv4 0xd7d0f4fd5825123 0t0 TCP 192.168.0.14:65510->sledge-cdg.slb.sfdcsvc.net:https (ESTABLISHED)
Google 14186 mohamedads 54u IPv4 0xd7d0f4fd5b3cbcb 0t0 TCP 192.168.0.14:49173->par21s19-in-f2.1e100.net:https (ESTABLISHED)
Google 14186 mohamedads 55u IPv4 0xd7d0f4fd5b41123 0t0 TCP 192.168.0.14:65511->sledge-cdg.slb.sfdcsvc.net:https (ESTABLISHED)
Google 14186 mohamedads 58u IPv6 0xd7d0f596050ecc3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:49163->[2a04:4e42:1d::720]:https (ESTABLISHED)
Google 14186 mohamedads 59u IPv6 0xd7d0f59605059c3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:65527->[2606:4700:4400::ac40:929e]:https (ESTABLISHED)
Google 14186 mohamedads 62u IPv6 0xd7d0f5960511dc3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:49181->[2001:4860:4802:36::36]:https (ESTABLISHED)
Google 14186 mohamedads 63u IPv4 0xd7d0f4fd583267b 0t0 TCP 192.168.0.14:49166->a104-124-109-108.deploy.static.akamaitechnologies.com:https (ESTABLISHED)
Google 14186 mohamedads 65u IPv6 0xd7d0f59605083c3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:65522->[2606:4700::6810:9440]:https (ESTABLISHED)
Google 14186 mohamedads 66u IPv6 0xd7d0f59605091c3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:65525->[2606:4700::6810:9440]:https (ESTABLISHED)
Google 14186 mohamedads 68u IPv4 0xd7d0f4fd582a123 0t0 TCP 192.168.0.14:65523->a23-220-25-199.deploy.static.akamaitechnologies.com:https (ESTABLISHED)
Google 14186 mohamedads 71u IPv4 0xd7d0f4fd5833bcb 0t0 TCP 192.168.0.14:49169->server-99-86-91-75.cdg50.r.cloudfront.net:https (ESTABLISHED)
Google 14186 mohamedads 72u IPv6 0xd7d0f59605108c3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:49172->[2600:9000:218c:4200:1f:f723:6fc0:93a1]:https (ESTABLISHED)
Google 14186 mohamedads 73u IPv4 0xd7d0f4fd5808123 0t0 TCP 192.168.0.14:65530->sledge-cdg.slb.sfdcsvc.net:https (ESTABLISHED)
Google 14186 mohamedads 74u IPv4 0xd7d0f4fd580767b 0t0 TCP 192.168.0.14:65531->sledge-cdg.slb.sfdcsvc.net:https (ESTABLISHED)
Google 14186 mohamedads 75u IPv4 0xd7d0f4fd5837bcb 0t0 TCP 192.168.0.14:49170->80.142.244.35.bc.googleusercontent.com:https (ESTABLISHED)
Google 14186 mohamedads 76u IPv6 0xd7d0f59605067c3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:49167->[2a04:4e42:54::396]:https (ESTABLISHED)
Google 14186 mohamedads 77u IPv4 0xd7d0f4fd5833123 0t0 TCP 192.168.0.14:49171->72.249.186.35.bc.googleusercontent.com:https (ESTABLISHED)
Google 14186 mohamedads 82u IPv4 0xd7d0f4fd5b3b67b 0t0 TCP 192.168.0.14:49177->chi.outbrain.com:https (CLOSE_WAIT)
Google 14186 mohamedads 84u IPv4 0xd7d0f4fd5831bcb 0t0 TCP 192.168.0.14:49178->chi.outbrain.com:https (CLOSE_WAIT)
Google 14186 mohamedads 85u IPv4 0xd7d0f4fd5831123 0t0 TCP 192.168.0.14:49179->151.101.9.140:https (ESTABLISHED)
Google 14186 mohamedads 87u IPv6 0xd7d0f5960512bc3 0t0 TCP [2a01:e34:ecb0:2610:e1d7:5d2e:8475:4d33]:49174->[2a04:4e42:1d::720]:https (ESTABLISHED)
Google 14186 mohamedads 93u IPv4 0xd7d0f4fd581fbcb 0t0 TCP 192.168.0.14:49180->server-13-32-145-15.cdg50.r.cloudfront.net:https (ESTABLISHED)
pycharm 37549 mohamedads 10u IPv6 0xd7d0f596050f3c3 0t0 TCP localhost:6942 (LISTEN)
pycharm 37549 mohamedads 46u IPv6 0xd7d0f5960510fc3 0t0 TCP localhost:63342 (LISTEN)
python3.9 39875 mohamedads 19u IPv4 0xd7d0f4fd5823bcb 0t0 TCP *:8501 (LISTEN)
python3.9 39875 mohamedads 20u IPv6 0xd7d0f59605116c3 0t0 TCP *:8501 (LISTEN)
python3.9 39875 mohamedads 29u IPv6 0xd7d0f596050c2c3 0t0 TCP localhost:8501->localhost:65493 (ESTABLISHED)
python3.9 43312 mohamedads 5u IPv4 0xd7d0f4fd581c67b 0t0 TCP localhost:commplex-link (LISTEN)
python3.9 44086 mohamedads 10u IPv4 0xd7d0f4fd581f123 0t0 TCP localhost:ddi-tcp-2 (LISTEN)
python3.9 44086 mohamedads 11u IPv6 0xd7d0f59605101c3 0t0 TCP localhost:ddi-tcp-2 (LISTEN)

Solution
You can use -p option to change the port (default: 5000) or you can use -h option to change the network address (default: 127.0.0.1).
Something like this will do the job. (If you haven't already used port 5001)
mlflow models serve -m mlflow_model/ -p 5001
Explanation
This is because your connection is in use as you can see on the errors.
[2022-07-24 14:11:16 +0200] [7534] [ERROR] Connection in use: ('127.0.0.1', 5000)
I think your 5000 port is already in use by mlflow ui but I'm not sure. You can check port 5000 by running this command in linux sudo lsof -i -P -n | grep LISTEN

Related

Enable port 443 on Linux Nginx

I'm trying to enable port 443 on Linux Nginx as I'm trying to install an SSL certificate. I've ran sudo lsof -i -P -n | grep LISTEN and got the following:
rpcbind 1751 rpc 8u IPv4 15914 0t0 TCP *:111 (LISTEN)
rpcbind 1751 rpc 11u IPv6 15917 0t0 TCP *:111 (LISTEN)
master 2172 root 13u IPv4 17752 0t0 TCP 127.0.0.1:25 (LISTEN)
nginx 2264 root 6u IPv4 19741 0t0 TCP *:80 (LISTEN)
nginx 2264 root 7u IPv6 19742 0t0 TCP *:80 (LISTEN)
nginx 2265 nginx 6u IPv4 19741 0t0 TCP *:80 (LISTEN)
nginx 2265 nginx 7u IPv6 19742 0t0 TCP *:80 (LISTEN)
nginx 2266 nginx 6u IPv4 19741 0t0 TCP *:80 (LISTEN)
nginx 2266 nginx 7u IPv6 19742 0t0 TCP *:80 (LISTEN)
sshd 7640 root 3u IPv4 1317041 0t0 TCP *:22 (LISTEN)
sshd 7640 root 4u IPv6 1317050 0t0 TCP *:22 (LISTEN)
sudo netstat -tulpn | grep :443 doesn't give any result either.
I ran sudo iptables -I INPUT -p tcp -m tcp --dport 443 -j ACCEPT but this didn't work. I did not get any results after this command.
My server is running on AWS EC2 and my security group has HTTPS enabled, but I still have the same issue.
My nginx.conf looks like this. I've added settings for a TLS enabled server listening on port 443:
server {
listen 80;
listen [::]:80;
server_name _;
location / {
root /home/ec2-user;
try_files $uri $uri/ /index.html;
# add_header 'Access-Control-Allow-Origin' '*';
}
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a TLS enabled server.
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name _;
root /home/ec2-user;
ssl_certificate "/etc/pki/nginx/server.crt";
ssl_certificate_key "/etc/pki/nginx/private/server.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers PROFILE=SYSTEM;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
First check if ngnix is running with systemctl status nginx
If not then there is something wrong with config file and I guess your ssl certificates are missing. If that is the case then try to generate certificates and place in same path as you mention in your nginx.conf with owner of that dir as nginx.

Node.js sever on ubuntu not receiving requests

When I place the IP Adress of the server and the port on the browser, there is no response and it does not get to the server. Here are some stats from the server; I am running the server on port 5403
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
80 ALLOW IN Anywhere
443 ALLOW IN Anywhere
5403 ALLOW IN Anywhere
22 (v6) ALLOW IN Anywhere (v6)
80 (v6) ALLOW IN Anywhere (v6)
443 (v6) ALLOW IN Anywhere (v6)
5403 (v6) ALLOW IN Anywhere (v6)
Another command
netstat -an | grep "LISTEN "
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:25324 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 :::5403 :::* LISTEN
You only listen to ipv6, this often pose a problem. Try to disable IPv6 and run on IPv4 address in stead.

Meteor App and Nginx on Port 80

My site shows always a blank page when I run Nginx on port 80. However if I run Nginx on an other port e.g. port 8080 and I go to mypage.com:8080 it shows my Meteor App. I have no idea why Nginx work on all ports but 80.
Here are my configs.
Nginx
server {
listen *:80 default_server;
server_name mypage.de;
access_log /var/log/nginx/app.dev.access.log;
error_log /var/log/nginx/app.dev.error.log;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header X-Forwarded-For $remote_addr;
}
}
Meteor App started with
sudo PORT=5000 MONGO_URL=mongodb://user:pwd#127.0.0.1:27017/mypage
ROOT_URL=http://mypage.de forever start -a -o out.log -e err.log main.js
netstat -tulpn shows
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 11214/nginx -g daem
tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN 10853/node
but as I said before mypage.de shows blank page... The same configs with Nginx on Port 8080 works. I working on Ubuntu. How can I fix this?
Your IP Tables seem to be blocking port 80. That or a firewall in between you and your server.
These are the IP Table rules for web traffic. Just run these commands on the command line:
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
I would also drop any rules that aren't needed like allowing port 5000. You only want people going to the web ports and that's it.

Why does Node.js work as a proxy to backend Node.js app, but not Nginx?

I have a simple nginx config file
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name ec2-x-x-x-x.compute-1.amazonaws.com;
#root /home/ec2-user/dashboard;
# Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
location / {
proxy_pass http://127.0.0.1:4000;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
But when I send the request, it says it cannot access the server.
the server works fine from port 4000 though, and sudo netstat -tulpn gives me this
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:80 0.0.0.0:* LISTEN 6512/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1640/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1247/master
tcp6 0 0 :::80 :::* LISTEN 6512/nginx: master
tcp6 0 0 :::22 :::* LISTEN 1640/sshd
tcp6 0 0 :::3000 :::* LISTEN 15985/node
tcp6 0 0 ::1:25 :::* LISTEN 1247/master
tcp6 0 0 :::4000 :::* LISTEN 3488/node
udp 0 0 0.0.0.0:68 0.0.0.0:* 484/dhclient
udp 0 0 127.0.0.1:323 0.0.0.0:* 451/chronyd
udp 0 0 0.0.0.0:1510 0.0.0.0:* 484/dhclient
udp6 0 0 ::1:323 :::* 451/chronyd
udp6 0 0 :::1458 :::* 484/dhclient
Also, when I use node as a proxy server
var http = require('http'),
httpProxy = require('http-proxy');
httpProxy.createProxyServer({target:'http://localhost:4000'}).listen(80);
this works just fine.
any ideas as to what I'm doing wrong?
Thanks for the useful netstat output. It appears the issue is that your Node.js app is only listening on IPv6, as represented by :::* in the output.
Nginx is trying to connect it via IPv4, where it is not listening.
Your Node.js proxy probably works because it shares the same issue on both ends. :)
You didn't share which Node.js version you are using. Some versions had an issue where attempting to set up an IPv4 connection would result in an IPv6 connection. Either you've run into a bug like that, or your Node.js app is actually misconfigured to listen on IPv6.
If the Node.js app on port 400 was correctly configured to listen on IPv4, you would see this kind of entry in the netstat output:
tcp 0 0 127.0.0.1:4000 0.0.0.0:* LISTEN 12345/node

Managing network interfaces for second node process in Meteor stack

I need to start a Meteor application in an infrastructure that have security restrictions applied to network interfaces.
Process must start binding to specific network interfaces, it's not possible to bind as - example : TCP *:26758
When Meteor stack is online and running, two node processes can be found. The second process is triggered when connection to Mongo is successfully established:
$ ps -ef |grep -E "node|mongo" |grep -v grep
meteor 13128 5668 9 14:52 pts/0 00:00:07 /home/meteor/.meteor/packages/meteor-tool/.1.1.3.1a15mwv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/node /home/meteor/.meteor/packages/meteor-tool/.1.1.3.1a15mwv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/tools/main.js --port 192.168.0.107:8080
meteor 13149 13128 3 14:52 pts/0 00:00:02 /home/meteor/.meteor/packages/meteor-tool/.1.1.3.1a15mwv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/mongodb/bin/mongod --bind_ip 127.0.0.1 --smallfiles --port 8081 --dbpath /home/meteor/apps/z1j-prod/.meteor/local/db --oplogSize 8 --replSet meteor
meteor 13205 13128 1 14:52 pts/0 00:00:01 /home/meteor/.meteor/packages/meteor-tool/.1.1.3.1a15mwv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/node /home/meteor/apps/z1j-prod/.meteor/local/build/main.js
I'm able to force interface bind for the first node process (pid 13128), but the second node process (pid 13205) starts listening in all interfaces:
lsof |grep meteor |grep LISTEN |grep node
node 13128 meteor 13u IPv4 244552 0t0 TCP oel70.node.com:webcache (LISTEN)
node 13128 13143 meteor 13u IPv4 244552 0t0 TCP oel70.node.com:webcache (LISTEN)
node 13128 13144 meteor 13u IPv4 244552 0t0 TCP oel70.node.com:webcache (LISTEN)
node 13128 13145 meteor 13u IPv4 244552 0t0 TCP oel70.node.com:webcache (LISTEN)
node 13128 13146 meteor 13u IPv4 244552 0t0 TCP oel70.node.com:webcache (LISTEN)
node 13128 13206 meteor 13u IPv4 244552 0t0 TCP oel70.node.com:webcache (LISTEN)
node 13205 meteor 11u IPv4 244597 0t0 TCP localhost:36099 (LISTEN)
node 13205 meteor 25u IPv4 244618 0t0 TCP *:26758 (LISTEN)
node 13205 13209 meteor 11u IPv4 244597 0t0 TCP localhost:36099 (LISTEN)
node 13205 13209 meteor 25u IPv4 244618 0t0 TCP *:26758 (LISTEN)
node 13205 13210 meteor 11u IPv4 244597 0t0 TCP localhost:36099 (LISTEN)
node 13205 13210 meteor 25u IPv4 244618 0t0 TCP *:26758 (LISTEN)
node 13205 13211 meteor 11u IPv4 244597 0t0 TCP localhost:36099 (LISTEN)
node 13205 13211 meteor 25u IPv4 244618 0t0 TCP *:26758 (LISTEN)
node 13205 13212 meteor 11u IPv4 244597 0t0 TCP localhost:36099 (LISTEN)
node 13205 13212 meteor 25u IPv4 244618 0t0 TCP *:26758 (LISTEN)
I start meteor with the following command: meteor --port 192.168.0.107:8080
This behavior it's the same using meteor's mongo instance or if using an external mongo instance
(export MONGO_URL=mongodb://mean.node.com:27017/meteor)
I'm using Meteor 1.1.0.2
Is possible to force interface binding for the second node process ??
Finally, I've found my answer after submitting an issue (thanks glasser !)
You can control the inner app port (including interface) with --app-port.
[root#oel70 ~]# lsof -P |grep meteor |grep LISTEN |grep node |sort
node 15302 15317 meteor 13u IPv4 119481 0t0 TCP oel70.node.com:8080 (LISTEN)
node 15302 15318 meteor 13u IPv4 119481 0t0 TCP oel70.node.com:8080 (LISTEN)
node 15302 15319 meteor 13u IPv4 119481 0t0 TCP oel70.node.com:8080 (LISTEN)
node 15302 15320 meteor 13u IPv4 119481 0t0 TCP oel70.node.com:8080 (LISTEN)
node 15302 15407 meteor 13u IPv4 119481 0t0 TCP oel70.node.com:8080 (LISTEN)
node 15302 meteor 13u IPv4 119481 0t0 TCP oel70.node.com:8080 (LISTEN)
node 15405 15409 meteor 11u IPv4 120974 0t0 TCP localhost:40219 (LISTEN)
node 15405 15409 meteor 25u IPv4 128339 0t0 TCP oel70.node.com:9080 (LISTEN)
node 15405 15410 meteor 11u IPv4 120974 0t0 TCP localhost:40219 (LISTEN)
node 15405 15410 meteor 25u IPv4 128339 0t0 TCP oel70.node.com:9080 (LISTEN)
node 15405 15411 meteor 11u IPv4 120974 0t0 TCP localhost:40219 (LISTEN)
node 15405 15411 meteor 25u IPv4 128339 0t0 TCP oel70.node.com:9080 (LISTEN)
node 15405 15412 meteor 11u IPv4 120974 0t0 TCP localhost:40219 (LISTEN)
node 15405 15412 meteor 25u IPv4 128339 0t0 TCP oel70.node.com:9080 (LISTEN)
node 15405 meteor 11u IPv4 120974 0t0 TCP localhost:40219 (LISTEN)
node 15405 meteor 25u IPv4 128339 0t0 TCP oel70.node.com:9080 (LISTEN)
[root#oel70 ~]#
You must start "meteor" as follows:
[meteor#oel70 z1j-prod]$ meteor --port 192.168.0.107:8080 --app-port 192.168.0.107:9080

Resources