dokku / dokku

A docker-powered PaaS that helps you build and manage the lifecycle of applications
https://dokku.com
MIT License
29.4k stars 1.92k forks source link

Node JS app not working #2532

Closed facundomedica closed 7 years ago

facundomedica commented 7 years ago

Description of problem:

I've installed Dokku using the one click app in Digital Ocean, in Ubuntu 16.04. I've tried running the Node JS sample of Heroku and it builds just fine and it outputs a url (Which is my server ip with the port). The problem is that when I put this url on my browser, it tries to load it for a long time but it does nothing. I think is something with related with ports, maybe?

(I'll try to complete most of the things below)

Output of the following commands

              total        used        free      shared  buff/cache   available
Mem:            488          77          65           5         345         371
Swap:             0           0           0

Client: Version: 1.12.4 API version: 1.24 Go version: go1.6.4 Git commit: 1564f02 Built: Tue Dec 13 00:08:34 2016 OS/Arch: linux/amd64

Server: Version: 1.12.4 API version: 1.24 Go version: go1.6.4 Git commit: 1564f02 Built: Tue Dec 13 00:08:34 2016 OS/Arch: linux/amd64

Containers: 8 --> THIS LOOKS ODD, I ONLY HAVE ONE APP Running: 1 Paused: 0 Stopped: 7 Images: 17 Server Version: 1.12.4 Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 36 Dirperm1 Supported: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: host bridge overlay null Swarm: inactive Runtimes: runc Default Runtime: runc Security Options: apparmor seccomp Kernel Version: 4.4.0-53-generic Operating System: Ubuntu 16.04.1 LTS OSType: linux Architecture: x86_64 CPUs: 1 Total Memory: 488.5 MiB Name: XsomenameX-dokku ID: LJ2H:FYCT:5DKP:AMOL:R6IL:T5F6:G2GN:OSXH:EASL:IXMS:JPQB:6J2A Docker Root Dir: /var/lib/docker Debug Mode (client): true Debug Mode (server): false Registry: https://index.docker.io/v1/ Insecure Registries: 127.0.0.0/8

0.4.0

herokuish: 0.3.19 buildpacks: heroku-buildpack-multi v1.0.0 heroku-buildpack-ruby v146 heroku-buildpack-nodejs v91 heroku-buildpack-clojure v75 heroku-buildpack-python v82 heroku-buildpack-java v46 heroku-buildpack-gradle v18 heroku-buildpack-grails v21 heroku-buildpack-scala v72 heroku-buildpack-play v26 heroku-buildpack-php v110 heroku-buildpack-go v44 heroku-buildpack-erlang fa17af9 buildpack-nginx v6 emberjs.tgz latest

0.7.2

plugn: 0.2.2 00_dokku-standard 0.7.2 enabled dokku core standard plugin 20_events 0.7.2 enabled dokku core events logging plugin apps 0.7.2 enabled dokku core apps plugin build-env 0.7.2 enabled dokku core build-env plugin certs 0.7.2 enabled dokku core certificate management plugin checks 0.7.2 enabled dokku core checks plugin common 0.7.2 enabled dokku core common plugin config 0.7.2 enabled dokku core config plugin docker-options 0.7.2 enabled dokku core docker-options plugin domains 0.7.2 enabled dokku core domains plugin enter 0.7.2 enabled dokku core enter plugin git 0.7.2 enabled dokku core git plugin logs 0.7.2 enabled dokku core logs plugin named-containers 0.7.2 enabled dokku core named containers plugin nginx-vhosts 0.7.2 enabled dokku core nginx-vhosts plugin plugin 0.7.2 enabled dokku core plugin plugin proxy 0.7.2 enabled dokku core proxy plugin ps 0.7.2 enabled dokku core ps plugin repo 0.7.2 enabled dokku core repo plugin shell 0.7.2 enabled dokku core shell plugin ssh-keys 0.7.2 enabled dokku core ssh-keys plugin storage 0.7.2 enabled dokku core storage plugin tags 0.7.2 enabled dokku core tags plugin tar 0.7.2 enabled dokku core tar plugin

Environment details (AWS, VirtualBox, physical, etc.): DigitalOcean

How was Dokku installed?: One click app

How reproducible:

Steps to Reproduce (After creating a dokku app):

  1. Clone this repository https://github.com/heroku/node-js-sample
  2. Push it to dokku
  3. Try to use the url in the output

Actual Results:

Not working

Expected Results:

See a "hello world"

Additional info:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful

josegonzalez commented 7 years ago

When you say "Not working", do you get an error page eventually, or just blank? Did you setup a firewall to stop non-80/443 port requests? Can I get a url for this app?

facundomedica commented 7 years ago

@josegonzalez Thanks for the swift response. It just keeps loading until browser fails ("Safari can't open the page"). I didn't set up anything, just used the one click app on Digital Ocean as said in many tutorials. The url I'm using is http://my.server.ip.address:43444. If you need the real one just ask.

More info:

dokku logs testing returns this: 2016-12-16T16:38:28.258861746Z app[web.1]: Example app listening on port 3000!

(3000 is not the real port, it was hardcoded, I do this actually: var port = process.env.PORT || 8080;, and now it shows port 5000)

Even more info:

Tried curl: curl: (7) Failed to connect to xxx.xxx.xx.xx port 43444: Operation timed out

josegonzalez commented 7 years ago

This doesn't sound like the default heroku nodejs app, since that one definitely listens on the proper port.

joshmanders commented 7 years ago

So to clarify you hardcode the 3000 port in the console log, but app.listen() uses var port = process.env.PORT || 8080?

josegonzalez commented 7 years ago

Def not the default app: https://github.com/heroku/node-js-sample/blob/master/index.js#L4

joshmanders commented 7 years ago

Yeah, I just did your reproduce steps and it works for me.

facundomedica commented 7 years ago

@joshmanders yes. @josegonzalez I was testing other things to try make it work. Now I've tried again the sample app (expecting a miracle or something) and didn't work.

So, with the default app it says: 2016-12-16T17:16:52.454899761Z app[web.1]: Node app is running at localhost:5000

I don't know how to debug this.

I've also tried rebooting my server, but didn't help

josegonzalez commented 7 years ago

Odd, maybe new node or whatever defaults to not listening on 0.0.0.0 interface. Thats what needs to happen, not localhost. I don't know enough about node, but if you fix that it should work fine.

joshmanders commented 7 years ago

Are you absolutely positive it is the node-js-sample app from heroku? Also make sure that you're not pushing and retrying the same port, as it should assign a new port to the next release.

facundomedica commented 7 years ago

@josegonzalez I've tried that (and just tried again) and it doesn't work. @joshmanders I'm 100% sure about that. What sounds weird is that it always returns the same port.

I'll try making a new app

joshmanders commented 7 years ago

Can you join the slack #dokku channel so that we can work through this in real time?

facundomedica commented 7 years ago

I'll document my steps here:

  1. git clone https://github.com/heroku/node-js-sample.git on my local computer
  2. On my server via ssh I do dokku apps:create nodesample
  3. cd node-js-sample on my local computer
  4. git remote add dokku dokku@xxx.xxx.xx.xx:nodesample on my local computer
  5. git push dokku master on my local computer
  6. Failure 👎

@joshmanders how do I join that channel?

josegonzalez commented 7 years ago

http://dokku.viewdocs.io/dokku/getting-started/where-to-get-help/

joshmanders commented 7 years ago

You can join us on slack at https://glider-slackin.herokuapp.com/

facundomedica commented 7 years ago

Okay, I joined the slack channel and @joshmanders guide me through a lot of steps just to find out that I had a firewall setted up. It was disabled using this command: sudo ufw disable.

joelgriffith commented 6 years ago

FWIW I recently ran into this: and the ufw above resolved my issue. More specifically I have my app on 3000, and had to do:

$ sudo ufw allow 3000

Might be good to add this as a note/step in the docs? I'd be happy to open a PR

josegonzalez commented 6 years ago

@joelgriffith mind making a pr?

As an aside, commenting an a year+ old issue isn't great etiquette, it notifies folks that may no longer be using the repo in question.

joelgriffith commented 6 years ago

Sure, can understand that sentiment, was hoping to help anyone later who's searching for resolutions later (which is how I stumbled upon this thread).