Problems opening a second http server (on different port) on an AWS EC2 instance

I have a meteor app that opens a second server to listen for web socket connections relating to my app. I’m using ws as my web sockets server library. I’ve picked a different port (8080, for example). On my local machine it all works swimmingly.

The app is deployed to AWS on an EC2 instance using mupx. The app itself works fine and my WebSocket server thinks itself successful in both opening and listening for incoming client activity on port 8080.

However, when I perform a netstat -an on my EC2 instance it reports no listener on port 8080. This is why my clients fail to connect to the WS server from the outside.

I have opened the port on AWS Security Group settings and confirmed potential access by running up a SimpleHTTPServer with python on 8080. So the issue does not concern the firewall.

I have reduced the problem further simply by opening a new http server within a server-only JS file on Meteor like so:

http = require('http');
var testserver = http.createServer(function (req, res) {
    var body = http.STATUS_CODES[426];
    res.writeHead(426, {
        'Content-Length': body.length,
        'Content-Type': 'text/plain'

This runs without error but again, netstat -an reports no listener on this port as per below:

ubuntu@ip-172-31-37-236:~$ netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0    *               LISTEN     
tcp        0      0*               LISTEN     
tcp        0      0       ESTABLISHED
tcp        0      0       ESTABLISHED
tcp6       0      0 :::80                   :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     
udp        0      0    *                          
udp        0      0 *                          
udp6       0      0 :::7175                 :::*                     

I’ve no clue why not. Any ideas?

mupx uses Docker and for your port to be accessible from outside the container you have to publish and expose it.

I had a similar scenario and modified mupx to fit my needs by adding the following two lines to the list of docker run parameters inside templates/linux/

--expose=8080 \ --publish=8080:8080 \

Hope that helps!

1 Like

You are a person of boundless beauty, expertise, learning and wisdom.

Thanks very much. :grinning: