Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

289
Visualizações
XAMPP ECONNREFUSED for localhost:3306

I am trying to connect to a MySQL database using the following video: https://www.youtube.com/watch?v=f5kye3ESXE8. My app.js file is as follows:

const express = require('express'); 
const bodyParser = require("body-parser");
const mysql = require('mysql');

const app=express()

app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())

//MySQL
const pool=mysql.createPool({
    connectionLimit : 10,
    host : 'localhost',
    user: 'root',
    password: '',
    database: 'nodejs_beers'
   
})

//want to  be able to get all beers in the database
app.get('', (req, res) => {
    pool.getConnection((err, connection) => {
        if(err) {
            console.log(err)
        }
        

        //query(sqlString), callback
        connection.query('SELECT * from beers', (err, rows) => {
            connection.release() //release the connection to pool

            if(!err){
                res.send(rows)
            }
            else{
                console.log(err)
            }
        })


    })
})

//make sure app is listening on 5000
app.listen(5000, () => console.log(`listen on port 5000`));

I've followed the video exactly, but I'm getting the following error when I attempt to enter "localhost:5000" into a browser:

[nodemon] starting `node app.js`
listen on port 5000
Error: connect ECONNREFUSED 127.0.0.1:3306

I've looked at xampp mysql doesn't run on port 3306 but I don't know how to get XAMPP to run MySQL on another port, and I can't find a my.cnf file to try and change it (if that is how it is supposed to be changed). I'm on MacOS Catalina and the XAMPP version is 7.4.2

I should also note that whenever I enter "localhost:8080" into a web browser, I'm brought to the "Welcome to XAMPP" page, which I believe means the Apache server is running correctly. I've double checked and I've got all 3 services running on XAMPP (Apache, MySQL, and ProFTPD).

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda