Warning: mysqli_connect(): (HY000/2002): An attempt was made to access a socket in a way forbidden by its access permissions

12,635

To get your connection string in a Web App with MySQL on CLearDB:

  1. select your service in Azure Portal
  2. click Settings
  3. select Application Settings and scroll down to Connection String and click in "Show connection string values"
  4. copy the middle column of the table you will get something like:

    Database=YOUR_DATABASE_NAME;Data Source=YOUR_HOSTNAME;User Id=YOUR_USERNAME;Password=YOUR_PASSWORD

That's it, copy and replace in your code!

Protip: you can ping YOUR_HOSTNAME and use the IP instead the HOSTNAME to improve speed ;)

Share:
12,635
user5786953
Author by

user5786953

Updated on June 05, 2022

Comments

  • user5786953
    user5786953 almost 2 years

    For two days yet I trying to resolve this problem

    Warning: mysqli_connect(): (HY000/2002): An attempt was made to access a socket in a way forbidden by its access permissions.

    My hosting is Azure and he has very bad interface. Programming language is PHP, I have database in same resource group with domain, account data is correct. what I do incorrect?

    line with problem

    mysqli_connect($SERVER, $USER, $PASSWORD, $DATABASE);