localhost:3306: MySQL and MariaDB connection fixes
Port 3306 is the default MySQL and MariaDB port. It is not a web page: connect with a client and fix refused connections.
Not a web pagePort 3306 belongs to a database. Connect with a client such as the mysql command, not a browser.
localhost:3306 is where MySQL or MariaDB listens by default. Opening it in a browser shows nothing useful, so use a database client or the mysql command instead.
What runs on localhost:3306
- MySQL and MariaDB servers (default port 3306)
- XAMPP, WAMP and MAMP MySQL (MAMP may use 8889)
- Docker containers started with
-p 3306:3306
Commands to start and test port 3306
mysql -h 127.0.0.1 -P 3306 -u root -psudo systemctl status mysqlsudo systemctl start mysqldocker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=change-me mysql:8Find what is using port 3306
Run these in a terminal on your computer. Nothing is sent to this site.
If localhost:3306 will not open
- ERROR 2002: Can’t connect through socket
- The server is not running, or the client is using a socket file instead of TCP. Start MySQL and connect with
-h 127.0.0.1to force a TCP connection. - Access denied for user
- The username or password is wrong. See MySQL access denied for root.
- Port 3306 is already in use
- Another MySQL service is running, for example MySQL80 on Windows. Stop it, or change the port. Use the port checker below.
- Host is not allowed to connect
- The user exists only for localhost. Create a user for the host you connect from.
Other ports like 3306
| Port | Usually used by |
|---|---|
| localhost:5432 | PostgreSQL |
| localhost:27017 | MongoDB |
| localhost:6379 | Redis |
| localhost:11211 | Memcached |
| localhost:1433 | Microsoft SQL Server |
| localhost:5984 | CouchDB |
| localhost:8983 | Apache Solr |
Questions about localhost:3306
- What runs on port 3306?
- MySQL and MariaDB database servers.
- How do I check if MySQL is running on 3306?
- Run the port checker command below. If a program listens on 3306, the server is up.
- Is localhost:3306 safe?
- Yes while it listens only on 127.0.0.1. If you open this port to a network, use a strong password, allow only trusted addresses in the firewall, and encrypt the connection. Do not expose a database port to the internet.
- Can I use a different port instead of 3306?
- Yes. Pick a free port above 1024, set it in the program, and open that number instead. If other programs connect to this port, change it there as well.
- How do I check what is using port 3306?
- Use the port checker on this page. It shows the command for Windows, macOS and Linux and does not send anything to this site.
Free tools that help
- Common ports listSearch a list of common TCP and UDP port numbers: SSH 22, HTTP 80, HTTPS 443, MySQL 3306, PostgreSQL 5432 and more, with dev server ports.