SSH Connection error - deploying a Django web app with PostgreSQL using the Azure portal

Dennis Chan 6 Reputation points
2020-09-23T08:40:10.833+00:00

Hi,

I've been doing the Tutorial: Deploy a Django web app with PostgreSQL using the Azure portal, and all is well until I get to Run Django database migrations. When I try to connect to the SSH, it errors with "ssh://root@172.16.3.3:2222 SSH CONNECTION CLOSE - Error: connect EHOSTUNREACH 172.16.3.3:2222Error: connect EHOSTUNREACH 172.16.3.3:2222Error: connect EHOSTUNREACH 172.16.3.3:2222Error: connect ECONNREFUSED 172.16.3.3:2222". I'm new at this so I'm thinking I'm doing something wrong, but I do not know what.
I've tried restarting my machine a couple of times, even restarted the tutorial and created another app but still the same result. I've also logged out and back into Azure, and none of them have worked. It may get connected initially but then it will Close after about 10 seconds.

Help please.

Thanks,
Dennis

Azure Database for PostgreSQL
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,963 questions
0 comments No comments
{count} vote

4 answers

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 18,366 Reputation points
    2020-09-23T17:32:51.26+00:00

    Thanks for asking question! You may try using the EXPOSE instruction to open port 2222 in the container. Although the root password is known, port 2222 is inaccessible from the internet. It's accessible only by containers within the bridge network of a private virtual network.

    EXPOSE 80 2222

    Reference: https://learn.microsoft.com/en-us/azure/app-service/configure-custom-container?pivots=container-linux#enable-ssh

    Also refer to Open an SSH session to a Linux container in Azure App Service for more details on SSH connection

    Let us know if you have further question on this.


  2. SnehaAgrawal-MSFT 18,366 Reputation points
    2020-09-24T07:58:35.813+00:00

    Apologize for the link and inconvenience with this issue! If I am right you are following Tutorial: Deploy a Django web app with PostgreSQL using the Azure portal and you are facing issue on step Run Django database migrations when trying to connect to SSH. Thanks for sharing context.

    Could you please try to open SSH session directly by pasting the following URL into your browser and replace <app-name> with your app name.

    https://<app-name>.scm.azurewebsites.net/webssh/host

    Also, note that If you're not yet authenticated, you're required to authenticate with your Azure subscription to connect.

    Sharing detailed document link below:
    https://learn.microsoft.com/en-gb/azure/app-service/configure-linux-open-ssh-session?WT.mc_id=Portal-WebsitesExtension

    Having said that If issue persists please send an email to AzCommunity[at]Microsoft[dot]com referencing this thread, we would like to work closer with you on this matter.

    0 comments No comments

  3. Dennis Chan 6 Reputation points
    2020-09-24T09:28:27.34+00:00

    Hi Sneha,

    I have previously attempted to open the SSH session directly a number of times but it always closes. This is after I have authenticated with my Azure account.

    Thanks for the new document link. I have attempted to open the SSH session from remote shell but I get this error "ValidationError: SSH endpoint unreachable, your app must be running before it can accept SSH connections.Use az webapp log tail to review the app startup logs".

    As advised, I shall log this via email.

    Thanks.
    Dennis

    0 comments No comments

  4. SnehaAgrawal-MSFT 18,366 Reputation points
    2020-09-28T14:12:07.2+00:00

    Thanks! This issue has been resolved as the web app container was failing to start up due to missing one of the modules "psycopg2" which was thus showing SSH connection error.

    Update: The tutorial-python-postgresql-app-portal has been now been updated by addition of following two lines in requirements.txt so that all modules are installed correctly.

    whitenoise
    psycopg2-binary