Unable to access app deployed on Dokku in a droplet

Posted January 29, 2021 2.7k views
DockerDokkuDeploymentDigitalOcean Droplets

I’ve deployed an app on Dokku using DigitalOcean’s droplet, but unfortunately I’m unable to access, I cannot make any requests to my app from outiside the dokku.

Here is the app’s server logs, the app server is running on port 5000(inside a docker container, I guess?)

2021-01-29T15:54:55.631984450Z app[web.1]: Puma starting in single mode...
2021-01-29T15:54:55.632155110Z app[web.1]: * Version 4.3.5 (ruby 2.7.0-p0), codename: Mysterious Traveller
2021-01-29T15:54:55.632257250Z app[web.1]: * Min threads: 5, max threads: 5
2021-01-29T15:54:55.632416330Z app[web.1]: * Environment: production
2021-01-29T15:54:59.477622282Z app[web.1]: D, [2021-01-29T15:54:59.477398 #10] DEBUG -- : BONSAI_URL not present, proceeding with Elasticsearch defaults.
2021-01-29T15:55:01.789462413Z app[web.1]: * Listening on tcp://
2021-01-29T15:55:01.790215291Z app[web.1]: Use Ctrl-C to stop

Here is my port mappings for the app

Proxy enabled:                 true
Proxy port map:                http:80:5000
Proxy type:                    nginx

Here is docker ps -a output

CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS                      PORTS               NAMES
29a40b74890a        dokku/propertysafe:latest     "/start web"             23 minutes ago      Up 23 minutes                                   propertysafe.web.1
159102b6127b        2ab94a5f043a                  "/bin/bash -c 'mkdir…"   23 minutes ago      Exited (0) 23 minutes ago                       naughty_sammet
a2dc93fff2dd        dd5cbe9f96db                  "/bin/bash -c 'mkdir…"   23 minutes ago      Exited (0) 23 minutes ago                       interesting_margulis
5861efa15abf        cc49b1d8e228                  "/build"                 26 minutes ago      Exited (0) 24 minutes ago                       peaceful_napier
e25ce8a7c7e2        9c8964c4fb67                  "/bin/bash -c 'cat >…"   26 minutes ago      Exited (0) 26 minutes ago                       dreamy_morse
410dbbc9cc4c        b197a493cfba                  "/bin/bash -c 'mkdir…"   26 minutes ago      Exited (0) 26 minutes ago                       crazy_hodgkin
5555c7890af0        gliderlabs/herokuish:latest   "/bin/bash -c 'mkdir…"   26 minutes ago      Exited (0) 26 minutes ago                       eager_meitner
287b083012b6        postgres:11.6                 "docker-entrypoint.s…"   2 hours ago         Up 2 hours                  5432/tcp            dokku.postgres.app_db

and the ufw firewall has permitted http traffic.

Everytime I make a hit to the droplet IP I get the connection refused error.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there @coderx,

What is the error that you get when you try to visit the app in your browser? As far as I can see from the docker ps output, the service is not exposing any ports.

I could suggest running the following command to check if your service is listening on the correct port on your host:

  • sudo netstat -plant

Feel free to share the output here!

  • Yeah it has to do something with docker container not exposing it’s port. How can I make the docker container expose it’s port automatically on deployment?

    I ran that command sudo netstat -plant and it gave the following output

    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
    tcp        0      0    *               LISTEN      2810/nginx: master  
    tcp        0      0 *               LISTEN      610/systemd-resolve 
    tcp        0      0    *               LISTEN      846/sshd: /usr/sbin 
    tcp        0    340      ESTABLISHED 2821/sshd: root@pts 
    tcp6       0      0 :::80                   :::*                    LISTEN      2810/nginx: master  
    tcp6       0      0 :::22                   :::*                    LISTEN      846/sshd: /usr/sbin

    In the browser I get an Connection refused error.

    • Hi there @coderx,

      As far as I can see you have Nginx running but you also have a Docker proxy setup for port 80. This could be causing the problem. Have you tried using only the Docker proxy instead of the Nginx service?


      • no, I haven’t tried that because I don’t know how to do that. I havent’t set up the nginx service or dokku proxy explicitly. They both have been set up by default.
        It would be helpful if you could tell me how to disable nginx to see what happens.

        I followed this deployment tutorial which apparently succeeds in the video but is causing problem for me.

        To me the problem is with the container not exposing its port 5000
        Here’s the output of docker ps

        CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS               NAMES
        b711e9b95929        dokku/propertysafe:latest   "/start web"             29 hours ago        Up 29 hours                             propertysafe.web.1
        7fc243c0be20        postgres:11.6               "docker-entrypoint.s…"   29 hours ago        Up 29 hours         5432/tcp            dokku.postgres.propertysafe_production

        and when I run docker port b711e9b95929 5000, it spits out

        Error: No public port '5000/tcp' published for b711e9b95929
      • I tried to disable nginx-vhosts plugin by running dokku plugin:disable nginx-vhosts and it threw error saying that Cannot disable a core plugin

  • Here is the output of dokku report my-app-name output

    -----> uname: Linux dokku-ubuntu-s-1vcpu-2gb-sgp1-01 5.4.0-52-generic #57-Ubuntu SMP Thu Oct 15 10:57:00 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
    -----> memory: 
                         total        used        free      shared  buff/cache   available
           Mem:           1987         399         194          15        1394        1418
           Swap:             0           0           0
    -----> docker version: 
           Client: Docker Engine - Community
            Version:           19.03.13
            API version:       1.40
            Go version:        go1.13.15
            Git commit:        4484c46d9d
            Built:             Wed Sep 16 17:02:52 2020
            OS/Arch:           linux/amd64
            Experimental:      false
           Server: Docker Engine - Community
             Version:          19.03.13
             API version:      1.40 (minimum version 1.12)
             Go version:       go1.13.15
             Git commit:       4484c46d9d
             Built:            Wed Sep 16 17:01:20 2020
             OS/Arch:          linux/amd64
             Experimental:     false
             Version:          1.3.7
             GitCommit:        8fba4e9a7d01810a393d5d25a3621dc101981175
             Version:          1.0.0-rc10
             GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
             Version:          0.18.0
             GitCommit:        fec3683
    -----> docker daemon info: 
            Debug Mode: true
            Containers: 9
             Running: 2
             Paused: 0
             Stopped: 7
            Images: 13
            Server Version: 19.03.13
            Storage Driver: overlay2
             Backing Filesystem: extfs
             Supports d_type: true
             Native Overlay Diff: true
            Logging Driver: json-file
            Cgroup Driver: cgroupfs
             Volume: local
             Network: bridge host ipvlan macvlan null overlay
             Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
            Swarm: inactive
            Runtimes: runc
            Default Runtime: runc
            Init Binary: docker-init
            containerd version: 8fba4e9a7d01810a393d5d25a3621dc101981175
            runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
            init version: fec3683
            Security Options:
              Profile: default
            Kernel Version: 5.4.0-52-generic
            Operating System: Ubuntu 20.04.1 LTS
            OSType: linux
            Architecture: x86_64
            CPUs: 1
            Total Memory: 1.941GiB
            Name: dokku-ubuntu-s-1vcpu-2gb-sgp1-01
            Docker Root Dir: /var/lib/docker
            Debug Mode: false
            Experimental: false
            Insecure Registries:
            Live Restore Enabled: false
    -----> sigil version: 0.6.0
    -----> herokuish version: 
           herokuish: 0.5.18
             heroku-buildpack-multi     v1.0.0
             heroku-buildpack-ruby      v218
             heroku-buildpack-nodejs    v175
             heroku-buildpack-clojure   v85
             heroku-buildpack-python    v177
             heroku-buildpack-java      v66
             heroku-buildpack-gradle    v31
             heroku-buildpack-scala     v87
             heroku-buildpack-play      v26
             heroku-buildpack-php       v179
             heroku-buildpack-go        v145
             buildpack-nginx            v14
    -----> dokku version: dokku version 0.21.4
    -----> dokku plugins: 
           plugn: 0.5.0
             00_dokku-standard    0.21.4 enabled    dokku core standard plugin
             20_events            0.21.4 enabled    dokku core events logging plugin
             app-json             0.21.4 enabled    dokku core app-json plugin
             apps                 0.21.4 enabled    dokku core apps plugin
             builder-dockerfile   0.21.4 enabled    dokku core builder-dockerfile plugin
             builder-herokuish    0.21.4 enabled    dokku core builder-herokuish plugin
             buildpacks           0.21.4 enabled    dokku core buildpacks plugin
             certs                0.21.4 enabled    dokku core certificate management plugin
             checks               0.21.4 enabled    dokku core checks plugin
             common               0.21.4 enabled    dokku core common plugin
             config               0.21.4 enabled    dokku core config plugin
             docker-options       0.21.4 enabled    dokku core docker-options plugin
             domains              0.21.4 enabled    dokku core domains plugin
             enter                0.21.4 enabled    dokku core enter plugin
             git                  0.21.4 enabled    dokku core git plugin
             logs                 0.21.4 enabled    dokku core logs plugin
             network              0.21.4 enabled    dokku core network plugin
             nginx-vhosts         0.21.4 enabled    dokku core nginx-vhosts plugin
             plugin               0.21.4 enabled    dokku core plugin plugin
             postgres             1.11.6 enabled    dokku postgres service plugin
             proxy                0.21.4 enabled    dokku core proxy plugin
             ps                   0.21.4 enabled    dokku core ps plugin
             repo                 0.21.4 enabled    dokku core repo plugin
             resource             0.21.4 enabled    dokku core resource plugin
             scheduler-docker-local 0.21.4 enabled    dokku core scheduler-docker-local plugin
             shell                0.21.4 enabled    dokku core shell plugin
             ssh-keys             0.21.4 enabled    dokku core ssh-keys plugin
             storage              0.21.4 enabled    dokku core storage plugin
             tags                 0.21.4 enabled    dokku core tags plugin
             tar                  0.21.4 enabled    dokku core tar plugin
             trace                0.21.4 enabled    dokku core trace plugin
    =====> propertysafe app information
           App deploy source:             
           App dir:                       /home/dokku/propertysafe
           App locked:                    false
    =====> propertysafe buildpacks information
           Buildpacks list:               
    =====> propertysafe ssl information
           Ssl dir:                       /home/dokku/propertysafe/tls
           Ssl enabled:                   false                    
           Ssl hostnames:                                          
           Ssl expires at:                                         
           Ssl issuer:                                             
           Ssl starts at:                                          
           Ssl subject:                                            
           Ssl verified:                                           
    =====> propertysafe checks information
           Checks disabled list:          none                     
           Checks skipped list:           none                     
    =====> propertysafe docker options information
           Docker options build:          --link dokku.postgres.propertysafe_production:dokku-postgres-propertysafe-production 
           Docker options deploy:         --link dokku.postgres.propertysafe_production:dokku-postgres-propertysafe-production --restart=on-failure:10 
           Docker options run:            --link dokku.postgres.propertysafe_production:dokku-postgres-propertysafe-production 
    =====> propertysafe domains information
           Domains app enabled:           true                     
           Domains app vhosts:            propertysafe.dokkuwala   
           Domains global enabled:        true                     
           Domains global vhosts:         dokkuwala                
    =====> propertysafe git information
           Git deploy branch:             master                   
           Git global deploy branch:      master                   
           Git keep git dir:              false                    
           Git rev env var:               GIT_REV                  
           Git sha:                       6ab0e28                  
           Git last updated at:                                    
    =====> propertysafe network information
           Network attach post create:    
           Network attach post deploy:    
           Network bind all interfaces:   false
           Network web listeners:
    =====> propertysafe nginx information
           Nginx access log path:         /var/log/nginx/propertysafe-access.log
           Nginx bind address ipv4:                                
           Nginx bind address ipv6:       ::                       
           Nginx error log path:          /var/log/nginx/propertysafe-error.log
           Nginx hsts:                    true                     
           Nginx hsts include subdomains: true                     
           Nginx hsts max age:            15724800                 
           Nginx hsts preload:            false                    
           Nginx proxy read timeout:      60s                      
           Nginx last visited at:         1612192337               
    =====> propertysafe proxy information
           Proxy enabled:                 true
           Proxy port map:                http:80:5000
           Proxy type:                    nginx
    =====> propertysafe ps information
           Processes:                     1                        
           Deployed:                      true                     
           Running:                       true                     
           Restore:                       true                     
           Restart policy:                on-failure:10            
           Ps can scale:                  true                     
           Status web.1:                  running    (CID: b711e9b95929)
    =====> propertysafe scheduler-docker-local information
           Scheduler docker local disable chown:                          
    =====> propertysafe storage information
           Storage build mounts:                                   
           Storage deploy mounts:                                  
           Storage run mounts:  
  • Hi @bobbyiliev I’m not running those containers explicitly, they are created and run by dokku itself when I push code for deployment. So, I’m not aware of how and where I would need to specify the expose command, as I have no Dockerfile which get run on deployment(don’t know whether it is even possible or not).
    On the other hand, it is not possible to expose port of a container that is already running. Therefore, I will first have to stop the container and run it manually by myself, also manually stopping the container breaks things, moreover for running that container again; I can’t possibly know what args were passed to that container when Dokku ran it on deployment (like the docker volumes etc).