I use curl -4 http://localhost but i get a curl: (7) Failed to connect to localhost port 80: Connection refused error

Using the Docker tutorial I’m stuck at this part: https://docs.docker.com/get-started/part3/#run-your-new-load-balanced-app

I use curl -4 http://localhost but i get a curl: (7) Failed to connect to localhost port 80: Connection
refused error.

output of previous step:
docker service ps getstartedlab_web

ID                  NAME                  IMAGE                      NODE                DESIRED STATE       CURRENT STATE            ERROR               PORTS
kqu5qggifnlm        getstartedlab_web.1   s1mpl3/get-started:part2   moby                Running             Running 29 minutes ago                       
prhrmm6hpop3        getstartedlab_web.2   s1mpl3/get-started:part2   moby                Running             Running 29 minutes ago                       
ytrwy5gxp2rk        getstartedlab_web.3   s1mpl3/get-started:part2   moby                Running             Running 29 minutes ago                       
mayvauijghbj        getstartedlab_web.4   s1mpl3/get-started:part2   moby                Running             Running 29 minutes ago                       
r625x2k7n6ta        getstartedlab_web.5   s1mpl3/get-started:part2   moby                Running             Running 29 minutes ago 

So error and ports are empty.

What should I analyse to fix this issue?

your services need to expose port 80

docker service update --publish 80:80 getstartedlab_web

thanks, I fixed it with using 4000:80 yesterday.

Hi s1mpl3. I have the same issue. What is the exact command you used to fix it?

I tried both of these but the issue persists:

“sudo docker service update --publish-add 4000:80 getstartedlab_web”
“sudo docker service update --publish-add 80:80 getstartedlab_web”

Thanks.