0

I want to connect the database to my app before uploading my website to the host but there is an error: connect ECONNREFUSED when i try to connect nodejs app to mysql database

I tried to connect it with mysql package for nodejs

4
  • The most likely cause is that MySQL Server is not running, or that there's no network route from your client to the database host. There's a manual page of further troubleshooting for that error here: dev.mysql.com/doc/refman/8.0/en/can-not-connect-to-server.html Commented May 28, 2023 at 18:19
  • Should i use remote access in this situation? Commented May 28, 2023 at 19:26
  • 1
    I can't tell from your description if you are trying to connect to a MySQL Server instance on your localhost, or if you're trying to connect to your MySQL Server instance on your website. If the latter, then yes it needs to be remote access. But you first need to make sure you have a network route and it isn't being blocked by firewalls. Read the manual page I linked to. Commented May 28, 2023 at 19:36
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented May 29, 2023 at 4:30

1 Answer 1

0
  1. Go to the Remote Database Access page in your cPanel dashboard.

  2. You will see a list of IP addresses and hostnames available for remote access.

  3. Try using any of these IP addresses or hostnames as the host in your database connection settings.

  4. Keep trying the options until you find the one that successfully connects.

Since Node.js acts as a separate server, it requires remote access permission to communicate with your cPanel's MySQL server.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.