Nginx – Docker: Can’t find the host in the upstream application: 9000

This composer file used to work until a week ago (no change). I ran it again at home by adding dns:8.8.8.8 to the docker-compose.yml file.

This leads me to believe that the problem is related to DNS.

Now I try to run it on a different machine (at work) but the following error occurs:
nginx:[emerg ] The host is not found upstream of “app:9000” on /etc/nginx/sites-enabled/default.conf:2

I am not sure what this means. This is my nginx conf:

server {
listen 80;
listen 443 ssl http2;

# Server name being used (exact name, wildcards or regular expression)
server_name localhost;
client_max_body_size 200M;

# Document root, make sure this points to your Phalcon web directory
root /var/www/html /public;
index index.php index.html;

location / {
try_files $uri $uri/ /index.php?_url=$uri&$args;
}

location ~ \.php${
fastcgi_pass app:9000;
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^( .+\.php)(/.+)$;
fastcgi_index index. php;

include fastcgi_params;

# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket /321
set $path_info $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APPLICATION_ENV development;

#add_header Authorization $http_authorization;
}

# Logging
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}

And my docker-compose.yml file:

db:
image: mysql:latest
container_name: dev_db
expose:
-"3306"
ports:
-"3307:3306"
environment:
MYSQL_DATABASE: dbname
MYSQL_USER: person
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: secret
app:
image: linxlad/php7-fpm
container_name: dev_app
tty: true
ports :
-"6900:6900"
volumes:
-./logs/php-fpm:/var/log/php-fpm
-..:/var/www /html
links:
-db
web:
tty: true
image: linxlad/nginx
container_name: dev_web
ports:< br />-"8080:80"
volumes:
-./conf/nginx:/etc/nginx/conf.d
-./logs/nginx:/var/log/ nginx
-..:/var/www/html
links:
-app

The repo is here.

Does anyone know how Correct this problem?

Thank you

Your nginx container may start before your application. You should add a depends_on section in the docker-compose.yml file to tell docker the order in which the containers should be started

https://docs.docker.com/compose/compose-file/#depends_on

web:
tty: true
image: linxlad/nginx
container_name: dev_web
ports:
- "8080:80"
volumes:
-./conf/nginx:/etc/nginx/conf.d
-./logs/nginx:/var/log/nginx
-..:/var/www/html
links:
-app
depends_on:
-app

This composer file used to work until a week ago (no change). I ran it again at home by adding dns:8.8.8.8 to the docker-compose.yml file.

This made me believe This problem is related to DNS.

Now I try to run it on a different machine (at work) but the following error occurs:
nginx: [emerg] host is in /etc/nginx/sites-enabled “app:9000” upstream on /default.conf:2 cannot be found

I am not sure what this means. This is my nginx conf:

server {
listen 80;
listen 443 ssl http2;

# Server name being used (exact name, wildcards or regular expression)
server_na me localhost;
client_max_body_size 200M;

# Document root, make sure this points to your Phalcon web directory
root /var/www/html/public;
index index.php index.html;

location / {
try_files $uri $uri/ /index.php?_url=$uri&$args;
}
< br /> location ~ \.php${
fastcgi_pass app:9000;
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/ .+)$;
fastcgi_index index.php;

include fastcgi_params;

# Bypass the fact that try_files resets $fastcgi_path_info
# see: http ://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APPLICATION_ENV development;

#add_header Authorization $http_authorization;
}

# Loggi ng
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}

And my docker -compose.yml file:

db:
image: mysql:latest
container_name: dev_db
expose:
-" 3306"
ports:
-"3307:3306"
environment:
MYSQL_DATABASE: dbname
MYSQL_USER: person
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD : secret
app:
image: linxlad/php7-fpm
container_name: dev_app
tty: true
ports:
-"6900:6900"< br /> volumes:
-./logs/php-fpm:/var/log/php-fpm
-..:/var/www/html
links:
-db
web:
tty: true
image: linxlad/nginx
container_name: dev_web
ports:
-"8080:80"
volumes:
-./conf/nginx:/etc/nginx/conf.d
-./logs/nginx:/var/log/nginx
-..:/var/ www/html
links:
-app

The repo is here.

Does anyone know how to correct this problem?

Thank you

Your nginx container may be started before your application. You should add one in the docker-compose.yml file The depends_on part tells docker the order in which the containers should be started

https://docs.docker.com/compose/compose-file/#depends_on

< pre>web:
tty: true
image: linxlad/nginx
container_name: dev_web
ports:
-“8080:80”
volumes:< br />-./conf/nginx:/etc/nginx/conf.d
-./logs/nginx:/var/log/nginx
-..:/var/www/html< br /> links:
-app
depends_on:
-app

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4606 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.