Container Running but Port is not available

Hello, I’m new to Docker and have been running into an issue.

When I run docker-compose, I have both my api and db containers running. However, when I navigate to the port, it seems that the port is not running. Any help would be greatly appreciated.


what exactly is the error-message and what was entered as URL into your browser?

Did you try to get logging data - either bei using docker container <container-name> logs (which is docker container api-1 logs in your case) on the command line or by clicking on the containername in the gui? Sometimes you can see helpful messages there, e.g. “could not connect to database”, “not allowed to write file”, …

Did you ensure that the application within the api-1-container is listening on port 8080? It happened to me in the past, that I forwarded computer’s port 80 to container’s port 80 but the application within the container was listening on port 3000 :slight_smile:

Have you checked that the application is running fine outside of the container? Maybe you have to change some application-settings (database-URL, …) to do so.

Thanks for the response!

  1. The error-message is just that I receive an empty response. I entered localhost:8080 to the URL.
  2. There were no logs on api-1, however when I try to run a new container on the same image, the new container’s logs showed that there was some errors loading my env files. I presume this is the issue, but I am unsure why this is the case.
  3. I am fairly certain it is running on 8080.
  4. I am not entirely sure what this means. Does this mean if it is running on my local machine?

Update: I have tried to hard code my env variables in my application and I am no longer getting any error messages or logs; however, the port is still not working.

Sorry for the delay.

The application is listening on which IP-address? If you configured the application to listen on it will not work within the container as the container’s localhost is not the same as the computer’s localhost. The applicatin has to listen on ip-address

At this point I would try the following:

  • try to start the app-container manually (without docker compose) with an interactive shell instead of the application docker run -it <imagename> bash and from this container’s shell start the application and check for errormessages
  • try to add some more debug-output to the console (e.g., the ip and port the app is listening on, the connection-string used for database-connection, queries sent to database, …) to see where the application is doing what.
1 Like

No Worries, I was able to figure it out! Super silly mistake on my part. Changing the address to fixed it for me.