• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Issue NodeJS cannot connect to MySQL database on same server

steve53

New Pleskian
Hi everyone,

I am running the latest Plesk on a Ubuntu server.

I have a domain (domain.com) and a subdomain called api.domain.com

I have installed a nodejs application for the api.domain.com via the interface and it is running and will return sample route return data as long as it is not querying the database.

I have installed a database under domain.com and it shows api.domain.com on the interface to the side where it says add-on domains also.

I have tried connecting to this database from my local machine and also from the node application but it will not work locally and I assume it will not work from the node application either.

I checked var/log/apache2/logs/error.log and it does not seem to throw an error for the initial connection in the start of the nodejs app:

const connection = mysql.createConnection({
host: 'localhost',
user: 'admin',
password: 'secretpassword',
database: 'app',
});

connection.connect(err => {
if (err) throw err;
console.log('Connected!');
});

because in the error.log it does show the Connected! so it seems to have a connection?

But in my test route nothing is shown except: 'Cannot GET /people/1' on the browser
I also have 2 different rows added with data in the people table within the app database.

app.get('people/:id', (req, res) => {

console.log('Fetching data with id' + req.params.id);
const id = req.params.id;
const queryString = "SELECT * FROM people WHERE id = ?";

connection.query(queryString, [id], (err, rows, fields) =>
{
console.log('I think we fetched'); // this does not show
res.json(rows);
});

});

In the database management for the user it is set to Allow remote connections from any host

From the firewall screen it seems to allow all incoming connections:
FTP server passive ports Allow incoming from all
rule-allow.png
Customer & Business Manager payment gateways Allow incoming from all
rule-allow.png
Single Sign-On Allow incoming from all
rule-allow.png
Plesk Installer Allow incoming from all
rule-allow.png
Plesk administrative interface Allow incoming from all
rule-allow.png
WWW server Allow incoming from all
rule-allow.png
FTP server Allow incoming from all
rule-allow.png
SSH (secure shell) server Allow incoming from all
rule-allow.png
SMTP (submission port) server Allow incoming from all
rule-allow.png
SMTP (mail sending) server Allow incoming from all
rule-allow.png
POP3 (mail retrieval) server Allow incoming from all
rule-allow.png
IMAP (mail retrieval) server Allow incoming from all
rule-allow.png
Mail password change service Allow incoming from all
rule-allow.png
MySQL server Allow incoming from all
rule-allow.png
PostgreSQL server Allow incoming from all
rule-allow.png
Samba (file sharing in Windows networks) Allow incoming from all
rule-allow.png
Plesk VPN Allow incoming from all
rule-allow.png
Domain name server Allow incoming from all
rule-allow.png
IPv6 Neighbor Discovery Allow incoming from all
rule-allow.png
Ping service Allow incoming from all



Hoping some of you can help me out with this headache, thanks!
 
Back
Top