Search code examples
amazon-web-servicesdockeramazon-ec2meteorubuntu-18.04

Web connection refused on EC2 Meteor deployment


I am using MUP to deploy a meteor app to an EC2 instance running Ubuntu 18. My deployment seems to work, but when I try to access the public URL of the instance in my browser, I get "connection refused." I'm going crazy with this one!

I assume this would be an AWS issue like a port not open, but my EC2 inbound rules seem like they should work: enter image description here

I SSH'ed into the instance to see if everything is working, and I think it is. For starters, the docker container seems to be running fine:

CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                NAMES
2b70717ce5c9        mup-oil-pricing:latest   "/bin/sh -c 'exec $M…"   About an hour ago   Up About an hour    0.0.0.0:80->80/tcp   oil-pricing

While still SSH'ed in, when I hit curl localhost:80 I get back HTML in the console, which suggests the app (a Meteor app) is running fine.

I checked to see if the Ubuntu firewall is active, and I don't think it is:

ubuntu@ip-172-30-1-118:~$ sudo ufw status verbose
Status: inactive

My ports also seem fine (as far as I can tell):

ubuntu@ip-172-30-1-118:~$ sudo netstat -tulpn | grep LISTEN
tcp        0      0 10.0.3.1:53             0.0.0.0:*               LISTEN      3230/dnsmasq
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      344/systemd-resolve
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      7903/sshd: /usr/sbi
tcp6       0      0 :::22                   :::*                    LISTEN      7903/sshd: /usr/sbi
tcp6       0      0 :::80                   :::*                    LISTEN      13597/docker-proxy

But when I go to Chrome on my local machine and try to access the site using the EC2 instance via the Elastic IP I've assigned (34.231.39.181) or via the EC2 address (https://ec2-34-231-39-181.compute-1.amazonaws.com/) I get :

This site can’t be reached
ec2-34-231-39-181.compute-1.amazonaws.com refused to connect.

I don't think it's a MUP issue, but here's the MUP config just in case that matters:

module.exports = {
  servers: {
    one: {
      host: '34.231.39.181',
      username: 'ubuntu',
      pem: [[MY PEM FILE]]
    }
  },

  hooks: {
    'pre.deploy': {
      remoteCommand: 'docker system prune -a --force' // PRUNE DOCKER IMAGES
    },
  },

  app: {
    name: 'oil-pricing',
    path: '../',
    servers: {
      one: {},
    },

    buildOptions: {
      serverOnly: true,
    },



    env: {
      ROOT_URL: 'https://ec2-34-231-39-181.compute-1.amazonaws.com/',
      MONGO_URL: [[MY MONGO URL]]
      PORT: 80,
    },



    docker: {
      image: 'abernix/meteord:node-8.15.1-base', // per: https://github.com/zodern/meteor-up/issues/692
    },

    enableUploadProgressBar: true
  },

};

When I run mup deploy everything checks out:

Started TaskList: Pushing Meteor App
[34.231.39.181] - Pushing Meteor App Bundle to the Server
[34.231.39.181] - Pushing Meteor App Bundle to the Server: SUCCESS
[34.231.39.181] - Prepare Bundle
[34.231.39.181] - Prepare Bundle: SUCCESS

Started TaskList: Configuring App
[34.231.39.181] - Pushing the Startup Script
[34.231.39.181] - Pushing the Startup Script: SUCCESS
[34.231.39.181] - Sending Environment Variables
[34.231.39.181] - Sending Environment Variables: SUCCESS

Started TaskList: Start Meteor
[34.231.39.181] - Start Meteor
[34.231.39.181] - Start Meteor: SUCCESS
[34.231.39.181] - Verifying Deployment
[34.231.39.181] - Verifying Deployment: SUCCESS

I'm using Meteor 1.8.1 if that matters.

Any help would be greatly appreciated!


Solution

  • Your sudo netstat -tulpn | grep LISTEN shows that you are listening on port 80. But you are using HTTPS in:

    https://ec2-34-231-39-181.compute-1.amazonaws.com
    

    This will connect to port 443, which nothing listens to. So either change your app to listen for HTTPS connections on port 443 (will require proper ssl certificates), or use HTTP which will go to port 80 (unencrypted):

    http://ec2-34-231-39-181.compute-1.amazonaws.com