"Failed to establish a new connection" Azure App Service

2023-06-09T07:12:41.9933333+00:00

We have a custom Docker image that runs a Tomcat and exposes port 7000 to handle traffic. We store this image in a container registry accessible from our Azure subscription.

We deploy the image using Azure App Service and use the WEBSITES_PORT configuration to bind the port 7000. However, the App Service fails to start with the following error in the App Service logs

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib64/az/lib/python3.6/site-packages/urllib3/connection.py", line 175, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/usr/lib64/az/lib/python3.6/site-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/usr/lib64/az/lib/python3.6/site-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
OSError: [Errno 113] No route to host
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib64/az/lib/python3.6/site-packages/urllib3/connectionpool.py", line 706, in urlopen
    chunked=chunked,
  File "/usr/lib64/az/lib/python3.6/site-packages/urllib3/connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "/usr/lib64/az/lib/python3.6/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "/usr/lib64/az/lib/python3.6/site-packages/urllib3/connection.py", line 358, in connect
    conn = self._new_conn()
  File "/usr/lib64/az/lib/python3.6/site-packages/urllib3/connection.py", line 187, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: 
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,974 questions
0 comments No comments
{count} votes

Accepted answer
  1. brtrach-MSFT 17,741 Reputation points Microsoft Employee Moderator
    2023-07-02T20:53:52.7433333+00:00

    @Bera, Aniruddha (GE Healthcare, consultant) In addition to the helpful answer shared by Anonymous, I wanted to share some further suggestions that might be helpful.

    It seems like your Azure App Service is failing to start with the error message "Failed to establish a new connection". The error message indicates that the App Service is unable to connect to the container registry where your custom Docker image is stored.

    This could be due to a few reasons such as incorrect registry path name, incorrect credentials, or the container registry is behind a virtual network using a private endpoint in an unsupported region.

    To troubleshoot this issue, you can try the following steps:

    1. Check that the path name to your container registry is correct. For a registry my-registry.io and image test/image with tag 3.2, a valid image path would be my-registry.io/test/image:3.2. You can refer to the registry path documentation for more information.
    2. Ensure that you have provided the correct credentials for the private registry you're trying to pull the image from.
    3. If the container registry is behind a virtual network, ensure that it is using a private endpoint in a supported region. You can refer to the list of supported regions for more information.
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2023-06-09T07:22:27.55+00:00

    change the internal port of docker container

    docker build -f Dockerfile -t test/tomcat-test:1.0 .
    docker run -d -p 4287:4287 --name tomcat-test test/tomcat-test:1.0

    build the image and run

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.