We present the first study of large-scale bars in clusters at intermediate redshifts (z = 0.4 - 0.8). We compare the properties of the bars and their host galaxies in the clusters with those of a field sample in the same redshift range. We use a sample of 945 moderately inclined disk galaxies drawn from the EDisCS project. The morphological classification of the galaxies and the detection of bars are based on deep HST/ACS F814W images. The total optical bar fraction in the redshift range z = 0.4 0.8, averaged over the entire sample, is 25%. This is lower than found locally, but in good agreement with studies of bars in field environments at intermediate redshifts. For the cluster and field subsamples, we measure bar fractions of 24% and 29%, respectively. In agreement with local studies, we find that disk-dominated galaxies have a higher bar fraction than bulge-dominated galaxies. We also find, based on a small subsample, that bars in clusters are on average longer than in the field and preferentially found close to the cluster center, where the bar fraction is somewhat higher than at larger distances.