I want to deploy a node.js app with pm2 and express into a Compute Engine Instance, it works fine in port 8080, but when i change the port to 8081, it returns me "500 Internal Server Error".
I also have a firewall rule with that port.
/etc/nginx/sites-available/default:
server {
listen 8081;
server_name **.***.***.***;
location / {
proxy_pass "http://127.0.0.1:8081";
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_cache_bypass $http_upgrade;
}
}
server {
listen 80;
server_name **.***.***.***;
root /var/www/html/;
}
In my file /home/myuser/.pm2/logs/index-error.log says: "ADDRESS ALREADY IN USE"
File: /var/log/nginx/error.log:
1260 768 worker_connections are not enough while connecting to upstream
I've tried with the next command: sudo.netstat -tulpn
And the only process that uses this port is the firewall rule that I create
Try this Below possible Solutions:
1)Set the maximum number of simultaneous connections that can be opened by a worker process. Please go through Worker_connections for more information. Also check full example configuration .
The formula for connections is worker_processes * worker_connections which should be 12 * 768, which would be (click clack) 9216. But your logs say 1768…
events {
worker_connections 10000;
}
Try this on your app.yml:
Any custom commands to run after building run:
exec: echo "Beginning of custom commands"
replace:
filename: "/etc/nginx/nginx.conf"
from: "worker_connections 768"
to: "worker_connections 2000"
replace:
filename: "/etc/nginx/nginx.conf"
from: "worker_processes auto"
to: "worker_processes 10"
Be aware that your block on post 2 is acting on the wrong file!
Another way to increase the limit is by setting worker_rlimit_nofile 10000 and had no issues, you can safely increase it, though, the chance of running out of file descriptors is minuscule. Package bbb-config
now sets worker_rlimit_nofile 10000
; and worker_connections 4000
; in /etc/nginx/nginx.conf
# 11347
Note: Note to CentOS / Fedora users, if you have SELinux enabled, you will need to run setsebool -P httpd_setrlimit 1
so that nginx has permissions to set its rlimit.
2)Check you may need to use a body parser to convert data to req.body
github.com/expressjs/body-parser
3)Check the problem is now a linux kernel limit, see easyengine.io/tutorials/linux/increase-open-files-limit
Please see similar SO for more information.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.