How to change default port for SQL Server on Linux

By:   |   Comments (2)   |   Related: > SQL Server on Linux


Microsoft released SQL Server to run on Linux servers. To secure the database environment, DBA's often change the SQL Server port from its default port 1433 to another available port number. In this tip we will see how we can make this change for SQL Server on Linux.


In a previous tip, Installing SQL Server vNext CTP1 on Red Hat Linux 7.2, we installed SQL Server on Red Hat Linux.  Once we have installed SQL Server on Linux, we can check the service status using the below command.

#check the status of mssql-server service.

systemctl status mssql-server

SQL Server service status

As we can see above, SQL Server is running on the default port 1433. In this tip we will explore how to change the port number.

Configuration of SQL Server on Linux with mssql-conf

As per Microsoft documentation, mssql-conf is a configuration script that installs with SQL Server vNext CTP 1.2 for Red Hat Enterprise Linux, SUSE Linux Enterprise Server, and Ubuntu. We can use this utility to set the following parameters:

  • TCP port: Change the port where SQL Server will listen for connections.
  • Default data directory: Change the directory for new SQL Server database data files (.mdf).
  • Default log directory: Changes the directory for new SQL Server database log (.ldf) files are created.
  • Default dump directory: Change the directory where SQL Server will deposit memory dumps and other troubleshooting files by default.
  • Default backup directory: Change the directory where SQL Server will send backup files by default.
  • Set traceflags: Set the trace flags that the service is going to use.
  • Set collation: Set a new collation for SQL Server on Linux.

Change default SQL Server TCP Port

Now suppose we want to change the default TCP Port of SQL Server from 1433 to 5500, follow the below steps.

1. Run the mssql-conf script as root with the "set" command for "tcpport". In the below query I specified tcpport 5500, but you can use whatever available port you would like.

sudo /opt/mssql/bin/mssql-conf set tcpport 5500

SQL Server service status

2. Restart the SQL Server service.

As we can see above, after we apply new tcpport, it gives notification to restart SQL Server service.

sudo systemctl restart mssql-server

SQL Server service status

3.We may need to run the below commands to open the SQL Server port on the firewall on the Linux server.

sudo firewall-cmd --zone=public --add-port=5500/tcp --permanent

sudo firewall-cmd --reload

SQL Server service status

4. Check the SQL Server service to the verify port has changed.

SQL Server service status

We can see now the SQL service is running on port 5500.

Next Steps
  • In another tip we will explore how to change the default location of data files and log files.
  • Read more SQL Server on Linux Tips

sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip

About the author
MSSQLTips author Rajendra Gupta Rajendra Gupta is a Consultant DBA with 14+ years of extensive experience in database administration including large critical OLAP, OLTP, Reporting and SharePoint databases.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips

Comments For This Article

Thursday, November 16, 2017 - 10:44:30 AM - rajendra Back To Top (69833)

 Hi, this setting has been changed in current release version, he network.tcpport setting changes the TCP port where SQL Server listens for connections. please use the below query


sudo /opt/mssql/bin/mssql-conf set network.tcpport <new_tcp_port>

Thursday, November 16, 2017 - 9:31:08 AM - Herrick Back To Top (69830)

It is saying we are not able to change the mssql port.

[r******k]:~# sudo /opt/mssql/bin/mssql-conf set tcpport 5500
The setting 'tcpport' is not supported.

get free sql tips
agree to terms