Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sorry for disturbing. I know my problem look common, but I really don't know what to make. Here is my code for getting a WMS layer in OpenLayers from Geoserver.

var wfs2 = new OpenLayers.Layer.Vector("WFS", {
                    strategies: [new OpenLayers.Strategy.Fixed()],
                    protocol: new OpenLayers.Protocol.WFS({          
                    version: "1.1.0",
                    url: "http://localhost:8080/geoserver/wfs",            
                    featurePrefix: "topp",
                    featureType: "states",
                    featureNS: "",
                    srsName: "EPSG:4326",
                    geometryName: "position"

So i get this problem in developer tools for chrome :

XMLHttpRequest cannot load http://localhost:8080/geoserver/wfs. Origin null is not allowed by Access-Control-Allow-Origin. 

in developer tools for chrome

I saw that people recommend to set up a proxy, but my .html is in the geoserver/data_dir/www folder, and don't call external urls.

I however tried it, so I created the folder cgi-bin in /usr/local/geoserver/cgi-bin/, where i put the proxy code I found here :

And then I added in the cript of my .html this : OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";

But I then get this error in developer tools :

Failed to load resource file://localhost/cgi-bin/proxy.cgi?url=http%3A%2F%2Flocalhost%3A8080%2Fgeoserver%2Fwfs 

Probably the proxy is not in the right place, but I don't think the first problem (without problem) comes from here.

Please help !

Thks a lot !

share|improve this question
If your html file is in geoserver/data_dir/www folder, how are you calling it in your browser? what is teh Url in your Browser? Does it start with http:// or file://? – Devdatta Tengshe May 24 '13 at 5:43
I access it this way : file://localhost/usr/local/geoserver/data_dir/www/map2.html – Gabriel May 24 '13 at 5:50
up vote 3 down vote accepted

You should access it through http protocol. file protocol is not allowed with a WFS server. see this StackOverflow question.

To test geoserver WFS try GetCapabilities request.

For your case try this:


More info at geoserver manual

share|improve this answer
yes, the right url was : localhost:8080/geoserver/www/map2.html Thks ! – Gabriel May 24 '13 at 16:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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