Two things happen that make it difficult to run a Node.js process on a non-default port.
First, Elastic Beanstalk uses load balancers. When a request hits your EB DNS (your-app.elasticbeanstalk.com) the load balancer directs the traffic to the least utilized instance (assuming you have multiple ec2 instances spun up for that environment). The load balancer default listens on port 80.
Using the AWS Elastic Beanstalk CLI, you can add other listeners to the load balancer using a command like this: elb-create-lb-listeners --lb <yourloadbalancername> --listener "protocol=http, lb-port=8080, instance-port=80"
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.elb.html
You also need to open the ports in the firewall of your EC2 instance. This is handled through Security Groups
By default, nginx is also listening to node on port 8081.
And you need to forward the IPTABLES.
commands:
00_iptables:
command: iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 6000 -j REDIRECT --to-port 6000
test: ! iptables -t nat -L | grep -i 6000
01_iptables:
command: iptables -t nat -A OUTPUT -p tcp --dport 6000 -j REDIRECT --to-port 6000
test: ! iptables -t nat -L | grep -i 6000