5

How can I figure out what instance my org is on (e.g. NA6, NA7) when I have a domain setup?

I have setup the custom domain https://custom-domain-dev-ed.my.salesforce.com as shown below. If I try to get the domain using

System.Url.getSalesforceBaseUrl().toExternalForm()

it is returned as

https://custom-domain-dev-ed.my.salesforce.com

If I can't figure out the domain then sites such as http://trust.salesforce.com/trust/maintenance/ and http://trust.salesforce.com/trust/status/ are useless to me.

enter image description here

6

Go to http://trust.salesforce.com/trust/status/# and click 'What instance am I using?'. It will show your instance name.

There have been reports that the domain lookup doesn't work all the time. If that is the case you can do a CNAME Lookup on your domain instead it will return something like this:

;; ANSWER SECTION: custom-domain-dev-ed.my.salesforce.com. 300 IN CNAME na17.my.salesforce.com.

  • Thanks. The domain lookup page doesn't seem to work for developer edition domains. I've got it to work for Production instances but not for dev editions (i.e. domains ending in dev-ed) – BarCotter Oct 14 '14 at 10:45
  • Maybe this is solution for your issue success.salesforce.com/answers?id=90630000000hWbMAAU they advised to use nslookup in order to check CNAME record, as a last resort you can ask SFDC support. – Marcin Sz. Oct 14 '14 at 11:09
  • Perfect. I've edited your Answer to include that information and also accepted it as the correct answer – BarCotter Oct 14 '14 at 11:28
  • New My domain lookup link: status.salesforce.com/status then click button "My Domain" – Enry May 3 '17 at 10:08
10

A SOQL Query on the Organization object will provide you with your org's InstanceName, regardless of whether you're using My Domain or not:

String instanceName = [select InstanceName from Organization limit 1].InstanceName;

--> NA31, CS9, etc.

Note, ensure that you run this query in a without sharing annotated class, otherwise the query will only be visible to System Administrators.

  • I was looking for a while this, it worked for me. Thanks! – Yucel Jun 23 '16 at 20:12
  • I believe that's api v31 and up only. – Cris Nov 9 '17 at 0:31
3

You can add your org to an Environment Hub and it will display you the instance on which the org is located. To get more infos about Environment Hub (it can do a lot of other useful things for you!), check this out: https://help.salesforce.com/HTViewHelpDoc?id=environment_hub_main.htm

enter image description here

  • Thank you for reply, I didn't know that something like this exists. The only drawback is that env hub is available only for: Enterprise, Performance, and Unlimited Editions. – Marcin Sz. Oct 14 '14 at 13:49
  • Yes, most of the candy comes at EE+ - I'm using the Hub since a couple of Months and it's really a cool feature, i. e. if your working with a number of different orgs. If you have a chance, try it. – Uwe Heim Oct 14 '14 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.