Network Issue
CS2
CS2: CreateBoundSocket Bind Error & MySQL Connection Failure - Fix Guide
🎯 Quick Answer
This error indicates a local database service failure; the primary fix is to verify and start the MySQL or MariaDB Windows service to resolve the port binding and connection issues.
SECTION 1: OVERVIEW
This error condition represents a compound failure in a Counter-Strike 2 (CS2) server environment utilizing SourceMod plugins. The primary error,CreateBoundSocket: ::bind to port 0 returned error [no name available](10049), indicates the server's inability to bind a network socket to a specified port, often a fallback or misconfiguration. The subsequent error, [admin-sql-prefetch.smx] Could not connect to database "default": [2003]: Can't connect to MySQL server on 'localhost' (10061), is the root technical failure. Error 10061 is a Windows Sockets error code for "Connection refused," meaning the TCP connection attempt to the MySQL database service on localhost (127.0.0.1) was actively rejected because no service is listening on the default port 3306. This problem occurs exclusively on Windows-based CS2 dedicated servers running SourceMod with database-dependent plugins. It is common in privately hosted servers where database services are manually managed. The severity is game-breaking for server administrators, as plugins requiring database access will fail to load or function, potentially crippling server administration, statistics, or item systems. The exact error codes present are 10049, 2003, and 10061.
SECTION 2: SYMPTOMS
The application logs the error sequence in theaddons/sourcemod/logs/ directory, typically in an error_*.log file. The server console or log file displays the exact lines: L 10/02/2021 - 18:23:22: [admin-sql-prefetch.smx] Could not connect to database "default": [2003]: Can't connect to MySQL server on 'localhost' (10061). This is often preceded by the CreateBoundSocket error. Observable symptoms include the failure of SourceMod plugins that rely on database functionality, such as admin authentication, player statistics, or item stores. These plugins may not load, or may generate continuous error messages. The server itself remains running, but core administrative features are non-functional. The error occurs during server startup or map change when plugins attempt to initialize and prefetch data from the configured database.
SECTION 3: COMMON CAUSES
Category: Service Configuration Error Specific technical explanation: The MySQL (or MariaDB) Windows service is not running. The database server process must be actively listening on TCP port 3306 (default) to accept connections. Error 10061 confirms the TCP SYN packet was met with an RST (reset) packet, indicating no listening socket exists on that port. Why this causes the problem: The SourceMod plugin attempts to connect tolocalhost:3306 but the connection is refused, causing the plugin initialization to fail.
Category: Configuration Error
Specific technical explanation: Incorrect credentials or database name in the addons/sourcemod/configs/databases.cfg file. The connection parameters defined for the "default" database entry do not match the actual database setup on the MySQL server.
Why this causes the problem: Even if the MySQL service is running, the plugin cannot authenticate or locate the specified database, resulting in a connection failure that may manifest similarly.
Category: Network Problem
Specific technical explanation: A local firewall rule (Windows Defender Firewall or third-party) is blocking the MySQL server executable (mysqld.exe) or port 3306 from accepting loopback (127.0.0.1) connections.
Why this causes the problem: The TCP connection from the CS2 server process (srcds.exe) to the MySQL process is blocked at the network layer, preventing successful socket communication.
Category: Software Conflict
Specific technical explanation: Another application or service is already bound to TCP port 3306 on the local machine, preventing the MySQL service from starting or listening.
Why this causes the problem: The MySQL service fails to initialize its network socket, leaving no endpoint for the game server to connect to.
Category: Configuration Error
Specific technical explanation: The MySQL server is configured to not listen on the TCP/IP port, or is configured to listen only on a specific network interface (e.g., 192.168.1.100) instead of all interfaces or localhost (127.0.0.1). This is controlled by the bind-address directive in the my.ini or my.cnf configuration file.
Why this causes the problem: The server is not accepting connections on the loopback adapter, making localhost or 127.0.0.1 unreachable.
Category: Game Bug / Plugin Issue
Specific technical explanation: An outdated or corrupted version of the admin-sql-prefetch.smx plugin or its dependencies. The plugin may contain a hard-coded connection string or method incompatible with the installed database server version.
Why this causes the problem: The plugin itself generates malformed network requests or uses deprecated authentication protocols, leading to a connection refusal.
SECTION 4: SOLUTIONS
Solution 1: Start the MySQL Windows Service
Difficulty: Easy Time Required: 2 minutes Success Rate: High Prerequisites: Administrator access to the server. Steps:- Press
Windows Key + R, typeservices.msc, and press Enter. - In the Services window, locate the entry for
MySQLorMariaDB. The exact name may vary (e.g.,MySQL80,MySQL57,MariaDB). - Examine the "Status" column. If it does not say "Started," this is the cause.
- Right-click the service and select Start. If the service fails to start, proceed to Solution 3.
- Verify the status changes to "Started."
mysqld.exe process is running and has successfully bound to its configured TCP port (default 3306), creating a listening socket that can accept the incoming connection from the CS2 server process.
Verification:
Re-launch the CS2 dedicated server and monitor the console or logs. The Can't connect to MySQL server on 'localhost' (10061) error should no longer appear. The admin-sql-prefetch.smx plugin should report a successful connection or load without error.
Solution 2: Verify Database Configuration in SourceMod
Difficulty: Medium Time Required: 5 minutes Success Rate: High Prerequisites: Knowledge of database credentials. Steps:- Navigate to the CS2 server's
addons/sourcemod/configs/directory. - Open the
databases.cfgfile with a text editor like Notepad++. - Locate the database configuration block named
"default". It will resemble:
`
"default"
{
"driver" "mysql"
"host" "localhost"
"database" "sourcemod"
"user" "root"
"pass" ""
// "port" "3306"
}
`
- Verify the
"host","database","user", and"pass"fields match a valid database and user on your MySQL server. Ensure the"port"is uncommented and correct if not 3306. - Save the file and restart the CS2 server.
(10061) to an access-denied message (e.g., ERROR 1045), indicating the service is running but credentials are wrong.
Solution 3: Configure MySQL Server Bind Address and Port
Difficulty: Advanced Time Required: 10 minutes Success Rate: High Prerequisites: MySQL server installed, access to its configuration file. Steps:- Locate the MySQL configuration file,
my.ini(Windows). It is commonly found inC:\ProgramData\MySQL\MySQL Server X.Y\or the MySQL installation directory. - Open the file with administrative privileges (e.g., Run Notepad as Administrator).
- Find the
[mysqld]section. - Ensure the
bind-addressline is set to0.0.0.0(all interfaces) or127.0.0.1. For local CS2 server use,127.0.0.1is secure. If the line is missing, add it:bind-address = 127.0.0.1 - Ensure the
portline is set to3306(or matches the port indatabases.cfg). - Save the file and restart the MySQL Windows service via
services.msc.
bind-address directive controls which network interfaces the MySQL server listens on. If set to a specific IP other than the loopback address, connections to localhost will fail. Setting it to 127.0.0.1 ensures it accepts local connections.
Verification:
Open Command Prompt as Administrator and run netstat -an | findstr :3306. You should see a line like TCP 127.0.0.1:3306 0.0.0.0:0 LISTENING. This confirms MySQL is listening on the correct interface.
Solution 4: Create Windows Firewall Allow Rule
Difficulty: Medium Time Required: 5 minutes Prerequisites: Administrator access. Steps:- Open Windows Defender Firewall with Advanced Security. Press
Windows Key + R, typewf.msc, and press Enter. - In the left pane, click Inbound Rules.
- In the right pane, click New Rule....
- Select Port and click Next. Select TCP, enter
3306in "Specific local ports," click Next. - Select Allow the connection, click Next. Apply to all profiles (Domain, Private, Public), click Next.
- Name the rule "MySQL Server (CS2)" and click Finish.
- Optionally, create an outbound rule with the same parameters.
srcds.exe and mysqld.exe. While loopback traffic is often allowed, restrictive firewall configurations can block it.
Verification:
Temporarily disable the firewall (for testing only) via the same wf.msc console. If the CS2 server error disappears, the firewall was the cause. Re-enable the firewall and confirm the new rule allows the connection.
Solution 5: Repair or Reinstall Database Plugin
Difficulty: Easy Time Required: 3 minutes Success Rate: Medium Prerequisites: Access to server files. Steps:- Navigate to the CS2 server's
addons/sourcemod/plugins/directory. - Rename
admin-sql-prefetch.smxtoadmin-sql-prefetch.smx.bak. - Obtain a fresh copy of the
admin-sql-prefetch.smxplugin. This is typically compiled from the.spsource file found in thescripting/directory or downloaded from a trusted SourceMod plugin repository. - Place the new
.smxfile into theplugins/directory. - Ensure all required database driver extensions (e.g.,
dbi.mysql.ext) are present in theextensions/directory. - Restart the CS2 server.
CreateBoundSocket error may originate from within the plugin's attempt to create a secondary network socket.
Verification:
The server log should no longer contain the specific [admin-sql-prefetch.smx] error line. If the error persists, the issue is environmental, not plugin-specific.
Solution 6: Test Database Connectivity Externally
Difficulty: Advanced Time Required: 5 minutes Success Rate: High (Diagnostic) Prerequisites: MySQL client tools installed (e.g.,mysql.exe in PATH).
Steps:
- Open Command Prompt.
- Test basic TCP connectivity to the MySQL port using:
telnet localhost 3306. If the command is not found, use PowerShell:Test-NetConnection localhost -Port 3306. - If the connection fails (telnet hangs or PowerShell shows
False), the MySQL service is not listening. Proceed to Solution 1 and 3. - If TCP connects, authenticate using the MySQL client with the credentials from
databases.cfg:mysql -h 127.0.0.1 -u root -p -D sourcemod. Enter the password when prompted. - If this command fails, the issue is with MySQL user permissions or the database not existing. You must create the database and user within MySQL.
telnet connection