skip to Main Content

I’m developing an ionic app which has to be connect with cpanel node.js mysql server. when server runs in cpanel it shows as server is running. but I can’t send requests from my app to the server. I’m confused with the server IP and port.

for node js server index.j file I have used port 3000 and host as localhost including mysql db username and pw. I tried to get response by using
url:http://(my cpanel Ip):3000/

var con = mysql.createConnection({
host: “localhost”,
user: “bdruser”,
password: “ABCD”,
database: “users”,
multipleStatements: true
});

when I send the requests by using postman it shows as could not get any response

2

Answers


  1. Chosen as BEST ANSWER

    I have fixed my issue. Whats wrong was firewall has blocked my port 3000. After it unblocked now my app is working very well with the cpanel backend server.

    Thanks!!


  2. Sorry but you are miles off from getting this right, and I can’t give a simple fix:

    • You must use https for feeds or Android won’t play nice.

    • You cannot connect to a mysql because then the servers password would be in your apps code and be a security risk

    • You are not connecting to the server in the right way anyway, localhost would only work if you were running that code on the same server as the mysql database.

    • Node.js is not for using within Ionic apps.

    What you need to do is something different but its not simple:

    • Set up a website on your cpanel server

    • Set up a webservice on there

    • Secure the webservice in a way that you can access it from Ionic

    • Connect the webserver to the mysql database

    • Write code to expose the data you want through the service

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search