Ruby + Nginx not working

So i’m trying to run a Ruby on Rails container to be accessed through the public URL, which means I need either to run it on port 80 or use Nginx (or similar tool) to redirect calls on port 80 to the port used in the Rails container, I’m trying using Nginx but haven’t been able to make it run, I get the error:

failed (111: Connection refused) while connecting to upstream, client:, server: ruby_test, request: "GET / HTTP/1.1", upstream: ""

My docker-compose file looks like:

version: '2'
    build: ./ruby_test
    privileged: true
      - "3000"
    build: ./nginx
      - ruby_test
      - "80:80"

My nginx.conf file looks like:

events {
    worker_connections  1024;

http {
    upstream ruby_test {

    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen       80;
        server_name  ruby_test;

        location / {
            proxy_pass http://ruby_test;
            #root   html;
            #index  index.html index.htm;

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;

    include servers/*;

… I know the rails container is runing well on port 3000 because I can curl localhost:3000 and get the response expected.

Also I know nginx.conf file is fine give I tried it locally ad it works.

Ant ideas what am I missing?

I think the in the nginx configuration you need to change:

upstream ruby_test {


upstream ruby_test {
   server ruby_test:3000;

Because the IP is a special IP address not intended as a target address. Since you linked the ruby_test container to the nginx container the ruby_test container should be resolvable as ruby_test to the docker internal IP address from the nginx container.


1 Like

I feel embarrassed, how did I miss this… and YES IT WORKED… thanks a lot!!!

1 Like