Phoenix Deployment, erconn refused

I have spent the past two days trying to deploy my app. I am using this tutorial as a guide because I already own a Ubuntu 16.04 droplet on Digital Ocean.

I am able to build a release and deploy the release to production with edeliver, so I run mix edeliver start production and it seems to start the daemon. But actually visiting the ip at port 8080 gets me nothing. If I curl the address I get a connection refused? I thought this was maybe Nginx so I messed around with the ufw settings for a little bit. How can I debug why my app is deploying, but now responding in the browser.

Are you sure your application is running on port 8080? The default path for phoenix applications is 4000.
Can you ssh into the droplet and check if the application is responding on localhost?

Welp, I am going between my MBA and iMac and just noticed my config/prod.exs was different. Updating it with the right ports, then trying again.

Just tried again. Still the same thing. in my prod.exs I use:

http: [port: {:system, "PORT"}],

And then:

PORT=8080 RELEASE_VERSION=0.0.1 envMIX_ENV=prod mix edeliver build release --verbose

env MIX_ENV=prod mix edeliver deploy release to production --version=0.0.1

I don’t get any errors. I just can’t connect to the site. If I curl port 80 I get the welcome to Nginx message. How should logging it to try and debug it?

Have you tried running the release manually and checking the log/console output and testing it (don’t forget to put PORT=8080 environment variable before your run command too)?

2 Likes

I am and there is nothing unusual. At first I thought it had something to do with Nginx (I’m relatively new to Ubuntu). Running it locally should I run the release with PORT=8080 bin/app_name foreground or my app with PORT=8080 mix phx.server? When I run it with foreground I still get conn refused when trying to connect to localhost:8080, but I can still curl localhost:80 and get the nginx welcome page. Should I still be able to connect to port 80 and get Nginx’s welcome page if I am running my app on port 8080? I just don’t know if this is what Nginx does.

EDIT: Okay so I ran the code with env MIX_ENV=prod PORT=8080 mix phx.server and this was my server:
Running BoostBuddyWeb.Endpoint with Cowboy using http://:::8080

Why are there colons where it should say localhost?

:: ist the IPv6 equivalent of 0.0.0.0, so your cowboy is listening on all available interfaces.

This is the default behaviour if I recall correctly.

If you use NGinX as a reverse proxy, then you should bind to localhost instead. That’s either 127.0.0.1 or ::1, I’d prefer the latter on dualstack systems.

But until you have verified that your installation is working correctly all together with Nginx you should keep the bound address at 0.0.0.0 (or IPv6 equivalent).

Also, the kind of questions you are asking here, shows that you do not have much experience in setting up a server and especially securing it. You really should ask some professionals to help you do it correctly. Servers not secured correctly can get very expensive, I learned that the hard way…

1 Like

You’re absolutely right. I don’t have much experience with servers, but this is also a project that I’m trying to learn how to do these kinds of things. I actually posted within the jobs board to look for a developer who can spend 8-12 hours refactoring, building tests, and helping me with my server deploy. I want to build a solid foundation for these kinds of things and I find its best to learn by doing. I’ve always had AWS or Heroku to deploy Rails apps and I’ll be the first to admit I realize that I was spoiled. That’s why I chose to use a Digital Ocean Droplet running Ubuntu 16.04 instead of Docker or Gigalixer.

My end plan though is to have it only accept connections through a ssh tunnel from a different Ubuntu server and that server will be set up to accept ssh from allowed IP addresses. Hopefully I will find someone to hire because I really want to learn as much as I can about being completely self sufficient at building and deploying phoenix applications.

If I go into my BUILD_AT folder and start a server with mix phx.server I can access the site by going to http://123.456.789.0987:8080/. I am not sure if this means much because I am not running my release with foreground or with a daemon.

I don’t get any errors. I just can’t connect to the site. If I curl port 80 I get the welcome to Nginx message.

  1. That sounds like your nginx is not configured to proxy requests
    to the phoenix app at all. Can you gist the config file?

  2. If you want to connect directly to e.g. 8080 for testing you need
    to confirm that port is open to connections: man iptables