How to access variables in a fieldset with variable_get function bi_mx_enhancement_form($form, &amp;$form_state) {
    $form['bi_mx_enhancement_government_ws'] = [
        '#type' =&gt; 'fieldset',
        '#title' =&gt; t('Government Web Service Settings'),
        '#tree' =&gt; true,
        '#collapsible' =&gt; true,
    ];
    $form['bi_mx_enhancement_government_ws']['base_url'] = [
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('Base URL'),
        '#default_value' =&gt; variable_get('base_url', 'https://'),
        '#description' =&gt; t('The base URL of the Government Web Service for Medic Validation. NOTE: Do not add a trailing slash.'),
        '#required' =&gt; true,
    ];

    return system_settings_form($form);
}


Variable base_url does not get saved, I always get the default value in the form.

I took a look at Drush, and it is like this:

bi_mx_enhancement_government_ws:
  base_url: 'http://52.203.204.11:8282/api/medicos'
Since you are setting #tree to TRUE, the values will be saved in the bi_mx_enhancement_government_ws persistent variable, which will contain an array. For the code you are showing, its value will be similar to the following one.

array(
  'base_url' =&gt; 'https://'
);


Instead of variable_get('base_url', 'https://'), consider using the following code.

$values = variable_get('bi_mx_enhancement_government_ws', array());
$ws_base_url = $values['base_url'];


When you are now using variable_get('base_url', 'https://'), you should use $ws_base_url.

Since you seem to just use a single setting for that fieldset, I would rather use '#tree' =&gt; FALSE, if that form doesn't have any other form field which is using base_url as identifier.