MySQL Database

Localhost 3306 Connection Error?

Port 3306 is the default port for MySQL. If you can't connect via Workbench or Terminal, check your service status.

Check Database Status
Kill Port 3306
npx kill-port 3306

Fixing MySQL "Can't connect to server"

The error Can't connect to MySQL server on 'localhost' (10061) usually means the service isn't running.

Step 1

Start the MySQL Service

Before trying to connect, ensure the daemon is active.

MacOS (Homebrew):
brew services start mysql
Windows (CMD as Admin):
net start mysql80

2. Check Port Bindings

If you have XAMPP or Docker running, they might have grabbed port 3306 first.

# Check what is using 3306
lsof -i :3306

Developer Port Reference Guide

Frontend & Web
3000 React / Node / Default 3001 React Secondary 5173 Vite / Vue 3 4200 Angular CLI 8000 Django / Gatsby 8080 Tomcat / Vue / Spring 8081 React Native 80 HTTP Standard 443 HTTPS / SSL
Backend & Infrastructure
5000 Flask / AirPlay 4000 Jekyll / Hexo 9000 SonarQube / PHP
Database & Cache
3306 MySQL 5432 PostgreSQL 27017 MongoDB 6379 Redis 11211 Memcached
DevOps & Data Science
8888 Jupyter Notebook 9200 Elasticsearch 9090 Prometheus 15672 RabbitMQ UI 8500 Consul 127.0.0.1 Loopback IP