Stuck At Getting Started Tutorial Part 8

I’m following the whole tutorial step by step and at Part 8. the app crashed during docker compose up -d with an exact same docker compose file as the tutorial. Logs are as follows:

app-mysql-1  | 2023-05-08 08:54:16+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.33-1.el8 started.
app-mysql-1  | 2023-05-08 08:54:17+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
app-app-1    | yarn install v1.22.19
app-mysql-1  | 2023-05-08 08:54:17+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.33-1.el8 started.
app-mysql-1  | 2023-05-08 08:54:18+00:00 [Note] [Entrypoint]: Initializing database files
app-mysql-1  | 2023-05-08T08:54:18.067167Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
app-mysql-1  | 2023-05-08T08:54:18.069607Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.33) initializing of server in progress as process 80
app-mysql-1  | 2023-05-08T08:54:18.131879Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
app-app-1    | [1/4] Resolving packages...
app-app-1    | success Already up-to-date.
app-app-1    | Done in 1.46s.
app-app-1    | yarn run v1.22.19
app-app-1    | $ nodemon src/index.js
app-app-1    | [nodemon] 2.0.20
app-app-1    | [nodemon] to restart at any time, enter `rs`
app-app-1    | [nodemon] watching path(s): *.*
app-app-1    | [nodemon] watching extensions: js,mjs,json
app-app-1    | [nodemon] starting `node src/index.js`
app-mysql-1  | 2023-05-08T08:54:42.445343Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
app-app-1    | Waiting for mysql:3306............
app-app-1    | Timeout
app-app-1    | Error: connect ECONNREFUSED
app-app-1    |     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) {
app-app-1    |   errno: -111,
app-app-1    |   code: 'ECONNREFUSED',
app-app-1    |   syscall: 'connect',
app-app-1    |   address: '',
app-app-1    |   port: 3306,
app-app-1    |   fatal: true
app-app-1    | }
app-app-1    | [nodemon] app crashed - waiting for file changes before starting...

Windows 11 Pro - OS Build: 22000.1817
Docker Version -
Cloud integration: v1.0.31
Version: 23.0.5
API version: 1.42
Go version: go1.19.8
Git commit: bc4487a
Built: Wed Apr 26 16:20:14 2023
OS/Arch: windows/amd64
Context: default

Server: Docker Desktop 4.19.0 (106363)
Version: 23.0.5
API version: 1.42 (minimum version 1.12)
Go version: go1.19.8
Git commit: 94d3ad6
Built: Wed Apr 26 16:17:45 2023
OS/Arch: linux/amd64
Experimental: false
Version: 1.6.20
GitCommit: 2806fc1057397dbaeefbea0e4e17bddfbd388f38
Version: 1.1.5
GitCommit: v1.1.5-0-gf19387a
Version: 0.19.0
GitCommit: de40ad0

Hey, seems like the app container started before the MySQL container, so when it tried to connect, it didn’t find the MySQL service. You can resolve this by restarting the app container within the stack via the Docker Desktop app, it should connect on the second try.

Image: How to restart a container within a stack