You might find yourself in a situation where you need to start MATLAB with a specific license file for troubleshooting purposes. If you are unsure of where you license file is, take a look at the article below:
Once you have located your license file, look below for the operating system that you are using MATLAB on and follow the directions that go along with it.
There are two ways to override the default license search path for MATLAB:
1. Using the "-c" startup flag for MATLAB
Using the -c flag will override any default license search paths unlike the MLM_LICENSE_FILE variable. The -c flag can be used to point to a specific license file (ex: license.lic or network.lic) or it can point to a specific license server (ex: email@example.com).
You can also manually specify the location of the license file with the -c option to the MATLAB startup script. This can be achieved by editing the "Target" field in the MATLAB shortcut.
- Right click on the MATLAB shortcut and choose "Properties"
- In the "Target" field, add -c and the path to the license file after the end quotation mark
- If you are trying to use a specific license file, write the name and filepath of the license file that you would like MATLAB to use. Your Target field will probably read similarly to the example below:
"C:\Program Files\MATLAB\R2022a\bin\matlab.exe" -c "C:\Program Files\MATLAB\R2022a\licenses\license_jamescomputer_123456_R2022a.lic"
If you are trying to point to a specific license server, you will instead add the port number followed by an @ symbol, and then the hostname. The result may look similar to the example below:
"C:\Program Files\MATLAB\R2022a\bin\matlab.exe" -c 27000@JAMESSERVER
4. Once you have finished modifying the Target field, you can select "OK" to save your changes and then launch MATLAB from the shorcut.
2. Using the environment variable MLM_LICENSE_FILE (or LM_LICENSE_FILE)
By setting the environment variable MLM_LICENSE_FILE (or LM_LICENSE_FILE), you can insert a new license search path for MATLAB. The variable value will be searched first, but this will not override the original search path. The value for this variable can either be a path to a license file, or it can be used in the port@host notation. For example, to have MATLAB check against the server "license1" on port 27000, you would set the variable value to be: 27000@license1.
For Mac, you can use the -c command when launching MATLAB through the Terminal application to have it point to a single license file to use.
- Click the magnifying glass in the top right corner of your screen so that Spotlight search opens.
- Enter "Terminal" and then open the first result.
- Open Finder, which usually resides on your Dock and is a face that is half blue and half grey.
- Click on "Applications"
- Find the release of MATLAB you would like to use. Right click on it and select "Show Package Contents"
- Open the folder "bin"
- Drag and drop the "matlab" file onto the terminal screen that you opened earlier. Terminal will probably read with something such as
8. Type in "-c" without quotation marks in the terminal
9. Drag and drop your license file that you downloaded into terminal. Your terminal line should now read with something such as
/Applications/MATLAB_2022a.app/bin/matlab -c /Users/james/Documents/MATLAB_licenses/license.lic
10. Press "Enter" or "Return" on your keyboard and MATLAB should open with the license file that you specified.
For Linux, you can use the -c command when launching MATLAB through the Terminal application to have it point to a single license file to use.
- Open Terminal
- Enter the name and file path of the MATLAB program. An example would be
This will vary depending on where you installed MATLAB and which release you are trying to use.
3. Type in "-c" without the quotation marks
4. Enter the name and file path of the license file you would like to use. An example would be
The command you have written so far should read something like this example:
/usr/local/MATLAB/R2022a/bin -c /home/james/Documents/license.lic
5. Enter the command and MATLAB should now run with the license file that was specified.